I understand the existence of #902, but the it seems the OP was looking for something different.
Sometimes I want Pipenv to handle one particular project differently than others. The most common problem is I don’t usually set PIPENV_VENV_IN_PROJECT
, but for some projects I want to do. This is however not possible, because they are loaded for shell
and run
, not install
etc., and even if they are, .env
is loaded during runtime, therefore doesn’t affect values in environments.py
.
direnv
and similar tools like autoenv
are not an option for me because they are all shell-depedent, and I operate in the command prompt on Windows.
My current workaround is to use a custom Dotenv loader, and a Batch script like this:
REM pipenv.bat
REM Shim to wrap Pipenv invocation in a loaded environment.
REM Put this in the project root so it’s picked up when you call "pipenv".
if exist ".env" (
dotenv-run pipenv %*
) else (
pipenv %*
)
which sort of works, but is suboptimal. I wish Pipenv could handle this more cleanly since it already loads .env files anyway.
pipenv install
with PIPENV_VENV_IN_PROJECT
setPIPENV_VENV_IN_PROJECT
, create .env
with PIPENV_VENV_IN_PROJECT=1
> pipenv install
Loading .env environment variables…
Installing dependencies from Pipfile.lock
Pipenv should go on reusing .venv
and perform operations.
> pipenv install
Creating a virtualenv for this project…
Pipenv goes on to create a virtualenv in the default location, not respecting values in .env
.
Hey @uranusjr thanks for another well thought out report. We were just discussing this internally and are on agreement that the desired behavior is as you describe. The fix is relatively simple but likely delayed until we have appveyor working
+1
Cool, super happy to know this is coming. Tell me if there’s anything I can do to help :)
we do not want to support this.
@kennethreitz I'd be interested to know what the reasoning for this is. It seems like it would be a useful feature to have.
This feature would be very useful to me, as well.
Most helpful comment
@kennethreitz I'd be interested to know what the reasoning for this is. It seems like it would be a useful feature to have.