Pipenv: Usage in Docker

Created on 24 Jan 2017  路  15Comments  路  Source: pypa/pipenv

What's the best workflow to use Pipenv with Docker?

I am trying to accomplish this with a Django project running inside Docker / Docker Compose.

Any tips / suggestions / ideas?

P.S. also, I am using https://github.com/yyuu/pyenv to automatically activate my virtualenvs and manage local Pythons. Does that not work well with this toolchain?

Most helpful comment

Does subsequent "pipenv run" knows the latest pipenv install has been executed with --system ? I have lot of issues on travis where (like in docker) I prefere to use the system's python instead of a virtualenv's one. Can pipenv run automatically finds out it need to use system's python?

(i also prefere using exactly the same chain of command between travis/docker and manual dev, instead of having to maintain 2 build scripts) ?

All 15 comments

this would be a replacement for that workflow

I see, thank you. Great work on this @kennethreitz!

Well, pyenv is more than just a virtualenv manager (in fact, that aspect comes only as a plugin). It's real use case is to manage multiple Python versions on a single machine, which seems orthogonal to the use case of pipenv. So I think the question remains if they play nicely together.

I believe that https://github.com/kennethreitz/pipenv/issues/98, which we're in the midst of debugging, is caused by a pyenv incompatibility.

So, what is the advised workflow in docker ? I have a project using pipenv that requires twisted that cannot be built into my alpine docker. I want to use the provided alpine package py-twisted. Can pipenv install the dependencies directly on the system and not on a virtualenv (it looks like pipenv install --system still creates a virtualenv) ?

@Stibbons, yes, you can use --system to install the packages directly on the system. It does create a virtualenv as part of it's initialization check but we're looking into making that more sensible. The created virtualenv won't be utilized unless you run pipenv install without --system.

Great !

Does subsequent "pipenv run" knows the latest pipenv install has been executed with --system ? I have lot of issues on travis where (like in docker) I prefere to use the system's python instead of a virtualenv's one. Can pipenv run automatically finds out it need to use system's python?

(i also prefere using exactly the same chain of command between travis/docker and manual dev, instead of having to maintain 2 build scripts) ?

It would be nice if we could set the use of --system as an environment variable (e.g. PIPENV_USE_SYSTEM). This would allow most commands and scripts to stay constant while using environment variables to change specific behaviors.

Good idea :) I use pipenv like usual in my docker, simply in prepend all command by pipenv run. This forces the use of a virtualenv inside the docker, maybe it is overkill. But I like the idea of the env var :)

I'm honestly only using Pipenv because I like the Pipfile format. I would be more than happy if I could decouple that from the virtualenv. Pipenv may be made for humans, but I really need it to be useful for computers (e.g. automation).

@clintonb Agreed. I really want to leverage the protection of the Pipfile.lock mechanism, but when I'm using Docker, I'd prefer to leave the virtualenv aspect aside. It'd be awesome if those two features could become usable independently.

Requirementslib has interfaces to both

Also as of next release I enabled auto_envvar_prefix so you might be able to do something like PIPENV_RUN_SYSTEM=1

Thanks @techalchemy!

Was this page helpful?
0 / 5 - 0 ratings