Pipenv: Specifying the project/Pipfile location as a command line argument

Created on 22 May 2018  Â·  1Comment  Â·  Source: pypa/pipenv

As far as I can tell, the pipenv command line tool always derives the project directory (Pipfile location) from the current working directory. Is there a way to tell pipenv which project directory to use as a command-line option? If not, is this a compelling feature request?

In my use case, I want to determine the venv path for a project from a script. I'd prefer not to change the current working directory just to invoke pipenv --venv in a shell process. Is there a stable API for doing this directly from Python? (Whereas the feature request to accept a project dir on the command line would be a similar API for shell scripting.)

Most helpful comment

There is a tool called pipenvlib which we don't spend a lot of time on but if you want to do this from a shell process you can temporarily set PIPENV_PIPFILE to point at the Pipfile of the relevant project and run pipenv --venv :

 ~/g/pypa-pipenv   master $…  set -gx PIPENV_PIPFILE /home/hawk/git/requirementslib/Pipfile
 ~/g/pypa-pipenv   master $…  pipenv --venv
/home/hawk/.virtualenvs/requirementslib-5MhGuG3C
 ~/g/pypa-pipenv   master $…  set -e PIPENV_PIPFILE
 ~/g/pypa-pipenv   master $…  pipenv --venv
/home/hawk/.virtualenvs/pypa-pipenv-PuUpLSqX

>All comments

There is a tool called pipenvlib which we don't spend a lot of time on but if you want to do this from a shell process you can temporarily set PIPENV_PIPFILE to point at the Pipfile of the relevant project and run pipenv --venv :

 ~/g/pypa-pipenv   master $…  set -gx PIPENV_PIPFILE /home/hawk/git/requirementslib/Pipfile
 ~/g/pypa-pipenv   master $…  pipenv --venv
/home/hawk/.virtualenvs/requirementslib-5MhGuG3C
 ~/g/pypa-pipenv   master $…  set -e PIPENV_PIPFILE
 ~/g/pypa-pipenv   master $…  pipenv --venv
/home/hawk/.virtualenvs/pypa-pipenv-PuUpLSqX
Was this page helpful?
0 / 5 - 0 ratings

Related issues

konstin picture konstin  Â·  3Comments

jacebrowning picture jacebrowning  Â·  3Comments

hynek picture hynek  Â·  3Comments

fbender picture fbender  Â·  3Comments

jerzyk picture jerzyk  Â·  3Comments