Pipenv: Can pipenv install have an option to set an explicit virtualenv directory name?

Created on 12 Oct 2017  Â·  4Comments  Â·  Source: pypa/pipenv

Motivation

Currently having minor issues using pipenv install as part of a Dockerfile, and being unable to get the virtualenv folder location programatically. ( Well I can but it's a bit meh)

The virtualenv folder name is returned by the virtualenv_name method property at https://github.com/kennethreitz/pipenv/blob/master/pipenv/project.py#L116

Currently I'm using ENV VIRTUALENV_PATH="$(pipenv --venv)" in my Dockerfile, but this seems messy.

Should there be an option to set an explicit virtualenv directory name?

Proposal

I propose a --virtualenv-name command line argument and a PIPENV_VIRTUALENV_NAME environment variable.

Most helpful comment

I'm also trying pipenv in a Dockerfile. After digging around in the pipenv source, I found PIPENV_VENV_IN_PROJECT. So the solution to this problem can look like this:

ENV PIPENV_VENV_IN_PROJECT 1
WORKDIR /var/lib/app
RUN pipenv install

You'd of course replace WORKDIR with your own.

Step 9/15 : RUN pipenv install
 ---> Running in 48a6f9074568
Creating a virtualenv for this project…
New python executable in /var/lib/app/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /var/lib/app/.venv

All 4 comments

I'm also trying pipenv in a Dockerfile. After digging around in the pipenv source, I found PIPENV_VENV_IN_PROJECT. So the solution to this problem can look like this:

ENV PIPENV_VENV_IN_PROJECT 1
WORKDIR /var/lib/app
RUN pipenv install

You'd of course replace WORKDIR with your own.

Step 9/15 : RUN pipenv install
 ---> Running in 48a6f9074568
Creating a virtualenv for this project…
New python executable in /var/lib/app/.venv/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /var/lib/app/.venv

I also think it will be useful if we can specify the venv name.

Alternatively you can do what other tools like Travis do and create your own virtualenv, activate it, and then use pipenv, which will respect the fact it is inside a virtualenv

Please note with the above approach that this will only work when the virtualenv is activated. If you choose to come back later without your previous environment activated, Pipenv will create a new default environment.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ipmb picture ipmb  Â·  3Comments

leileigong picture leileigong  Â·  3Comments

jerzyk picture jerzyk  Â·  3Comments

jacek-jablonski picture jacek-jablonski  Â·  3Comments

bgjelstrup picture bgjelstrup  Â·  3Comments