-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let user choose location of .venv #4213
Comments
Hey there, sorry you're running into this frustration -- I've struggled with this myself and I definitely hear you. You have a couple of options already which address this use case broadly speaking -- not all of these will apply to your specific use case but I will include them in case they help anyone else:
As for the comment in there about pipenv writing everything it sees, yeah, that issue is also super annoying. I expect to tweak that API a bit sometime soon to try and make that a bit less painful. Let me know if any of that can meet your use case -- thanks! |
Perhaps this is the wrong thread for this comment, but I've been burned by this too. I was deploying my app to my production environment and it wasn't working. After a bunch of debugging, I remembered the It sounds like I could manually create a 2 cents. |
Follow up after searching about the
It's kind of like git or many apps that walk up from the current directory, looking for config until you find it. So start at the most local level (the app root), check there, and if not, keep going. |
If |
Documentation help is always welcomed! Feel free to submit a pull request and ping me for review. |
Hi! I would love to be able to contribute to docs, but am still mostly a confused newbie. I did try setting the But here are a couple of documentation suggestions: On page https://pipenv.pypa.io/en/latest/advanced/#configuration-with-environment-variables
I would modify it to read something to the effect
I think people look for “local” when they’re trying to figure this setup out. Also this would specify that it changes the installation target. The other pertinent page https://pipenv.pypa.io/en/latest/install: In the subsection “Isolated Installation of Pipenv with Pipx” under “Installing Pipenv”? Is this what I should be doing instead of Otherwise, it would be helpful to have a tiny mention on the “PIPENV_VENV_IN_PROJECT” parameter under the “Installing packages for your project” since it seems applicable here. Currently, the blurb is this
A possible tiny modification could be
|
To what? What does it do? It's not documented. I just want a simple option to give pipenv a path where it should create or use an existing virtal environment. |
It is definitely possible to specify the location of the virtual env using a combination of the following:
I will try to give an example later. |
@ZelphirKaltstahl but pipenv should create and activate the virtualenv as necessary, otherwise you way as well just use |
That would be nice of course. There is a qualitative difference between pip freeze and a lock file such as Pipenv creates. Namely, that it stores hashes and does so in one tool. If you wanted to get that from pip, you would need additional tools to get really "frozen" dependencies. Which is possible, but not as easy to use. Anyway, here is how you can do it: https://notabug.org/ZelphirKaltstahl/python-pipenv-usage/src/master/usage.md Note, that this script is probably a bit overcomplex, as it takes care of installing pip, virtualenv and pipenv itself with defined hashsums and putting many things into variables. This is done for reproducible results. The only thing still without checksum is setuptools, but you could probably easily copy the approach from the other installed tools. I recommend trying this script inside a virtual machine first, to understand what it does and only then make use of the parts you need. This is also what I did for testing it. I ran it in a Debian 10 VM. |
This isn't intended to be a criticism because I think pipenv is a wonderful tool. But rather to place the framing of this issue back to "feature request" rather than a "how do I...?" string of work-arounds. I think the point of this issue report is that people have a use-case where pipenv is a fully featured venv management solution (as the name and docs suggest it is); but currently it is a kind of enhanced dependency manager that can work within a venv or will create an opinionated one for its own use as a kind of side-effect. What it does is great, but people (including myself) seem to want a more complete solution that incorporates the really great features of pipenv within a comprehensive venv manager. We're tired of separate env management like conda and workarounds like those suggested by @ZelphirKaltstahl, creating a venv first then managing it with pipenv, and we see the potential that exists in pipenv to fill this role. A fully realized venv manager would have the ability to specify where the venv files should be located and do what is needed (like maintain the Maybe this notion goes beyond the scope and goals of the project, which is completely fine. If that's the case, then maybe the docs just need to reflect the purpose of the project more clearly so people can easily see that complete management of venvs isn't a use-case pipenv addresses and move on to other solutions. |
Note, that the script I linked does not seem to work in newer version
If answered with It seems, that this workflow is now broken and that truly you cannot use existing virtualenvs any longer for installing your packages in them using Pipenv. If anyone knows another workaround, I'd like to know it. |
This is supported now with https://pipenv.pypa.io/en/latest/advanced/#pipenv.environments.Setting.PIPENV_CUSTOM_VENV_NAME |
Works like a charm! Many thanks for that!! Just a hint, I haven't found this feature in the official docs. |
It's now at https://pipenv.pypa.io/en/latest/configuration/#pipenv.environments.Setting.PIPENV_CUSTOM_VENV_NAME |
It's irritating that you cannot specify custom virtual environment directory location. It makes pipenv unsuitable for production deployments.
PIPENV_VENV_IN_PROJECT
is suitable only for development environments.Consider this scenario using docker-compose.yaml to set up a Docker container:
Here the project is deployed out of Git/CI/CD into
/srv/deploy/app
and is mounted read-only to containers at/app
, because more containers share the same code and they have no business overwriting it. But this means that/app/.venv
cannot be created in containers.This is very specific example I'm now just dealing with, but having virtual environment in
/var/cache
or any other volatile directory seems to be perfectly legal usage.I've experimented with exporting
VIRTUAL_ENV
prior to runningpipenv install
but it is ignored.This issue was previously closed here #746.
The text was updated successfully, but these errors were encountered: