-
-
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
pipenv install --target /path/to/my/virtualenv/folder #746
Comments
Hey @foxmask, you can set the PIPENV_VENV_IN_PROJECT environment variable to have pipenv place the .venv directory inside your project rather than with the others in .local. This is likely the closest we'll get to your current request for now. Hopefully that helps accomplish what you're looking for. Thanks for taking the time to check in on this! |
I saw it but the ~/fox_venv/projectA/.venv/ folder is not the folder I've chosen, but if it's how that has to work, I bow. |
See https://docs.pipenv.org/advanced.html#custom-virtual-environment-location |
the pip install --target have other uses than using a venv I use I would be really good to use |
I want this feature too. I've the private repo to be included in
|
It is a shame that there can't be a hook that just sets WORKON_HOME for that invocation or set's it for the project context. |
I was able to workaround with:
|
It seems that supporting this feature would not be too much work, since pipenv run pip install -r <(pipenv lock -r) --target dist/ |
@kevinkjt2000 Yeah, our code base is so easy you never contributed anything. |
@uranusjr I acknowledge that you have a collaborator badge, but that is a rather sarcastic comment to make... I encourage you to encourage potential new-comers instead of steering the github comment section into frivolous, insulting conversations. If you would like more contributors; instead, try confirming or denying comments as they are made. Sarcasm is rather off-putting. I used the word My comment pointed out that |
That being said, I'm willing to take a crack at this. I shall poke around for a bit, and see if there is a place to inject the |
@kevinkjt2000 @uranusjr is as much of a core maintainer as it is possible to be at the moment, no matter what his tag says, but you're right that you are just trying to help and I'm quite sure he misunderstood your intentions, so firstly apologies for that Technically you're right, pipenv can really support anything because you can |
This? https://github.com/pypa/pipenv/blob/master/pipenv/core.py I noticed this call to Line 944 in e86e7cf
Is the goal to not allow more calls to pipenv run in this core.py file (since it is being "well oiled")? I think this is the location where --target could be supported, something like "pipenv run pip install --target {0} -r {1}" (where {1} would be some temporary file that contains pipenv lock -r 's output)?
|
@kevinkjt2000 no, i don't mean literally 'the core.py file in pipenv', I mean we will consider adding functionality like |
Whoops, I should have said |
if you can't use
Update: I use the following command for my lambda:
|
I would also like this feature to be able to deploy whole virtualenvs. Since virtualenvs can not easily be moved they must be created at their final location. |
While I do not object to this feature per se, shipping whole virtual environments is never a good idea. I would recommend looking into alternative packaging methods such as zipapp. |
Since you are featuring PEP 441 I want to point people reading towards https://github.com/pantsbuild/pex too. It's makes use of PEP 441 and is pretty straight forward. While that is all nice PEP 441 has some downsides: It doesn't allow bundling a specific python interpreter, django settings.pys get harder to handle, etc. Why do you think it's never a good idea? |
Someone recommended me cf_Freeze a while ago https://anthony-tuininga.github.io/cx_Freeze/ to package whole python setup. Any opinion on this tool ? |
@HerrSpace Because it is against the developers’ intentions. pypa/virtualenv#1035 cx_Freeze is a fine tool, but has a quite specific purpose. It does not support all use cases as a result, and is probably not @HerrSpace is looking for (considering the mention of Django). |
@uranusjr Interesting, thank you! That said I have previously deployed prebuild virtualenvs with some success in very homogeneous systems. The CI and production systems were basically identical. |
Yeah, I wouldn’t be surprised it works if the base systems are more or less the same. This is essentially how many package managers (e.g. APT) works, really, by pre-building binaries with a well-controlled environment, and copy them to the exact location that works. Python ecosystems are unfortunately not that well-controlled, and don’t generally incline to support this usage. It would work, but you’ll be on your own. |
Aye, I guess PEP 441 is where the journey is going. |
Oh and—if you’re into the bleeding edge stuff, PEP 582 might be worth a read. It is essentially |
We would like this feature. We have a large team working on a project. We would like to create the virtual environment in the root of the project. We wouldn't check the environment in, but we would check the IDE config in which would reduce the number of steps team members need to take in order to get up and running on the project. |
@johneast just use |
There is a number of people including myself requesting this feature, so maybe the ticket should be reopened? |
The feature exists. You can set Note that a few people asking for a feature isn’t a justification for including it or an explanation for why the need isn’t met by existing functionality. We have a process if you do feel there is a real need after evaluating existing options; you will need to submit a pull request to the |
Justification: pipenv's default location is in my home dir. At my office the home dir is over network mount and rather slow both in terms of latency and throughput. Thus lunching a python program that has lots of imports can take up to 20 seconds! If instead I install the venv on a local mount then load time drops to 2 seconds. The problem with |
Justification: In a world with docker containers and developers that prefer to use a "local environment" to develop rather than a docker container because things like interactive debugging, live-reload, and IDE integrations are more easily connected without extra work; I require a feature like this so that I can select a path that does not collide with the developer location ( set via the PIPENV_VENV_IN_PROJECT env variable in the project dir ) with the location ultimately used in build utils and in the released container. I find I keep looking for a solution and come to one conclusion consistently: do not use pipenv to maintain the virtualenv. This is the pattern I see in the comments and I hope others do as well. I offer this feedback because I respect your efforts and want to ensure a portion of your user's needs are well understood. I am not asking for feature creep as much as I am asking for support for an edge case we seem to find ourselves within. |
Here's a concrete example of what @jpcope is describing, which is impossible with the current version of WORKDIR /app
COPY ./Pipfile /app/
COPY ./Pipfile.lock /app/
RUN env PIPENV_SKIP_LOCK=1 \
PIPENV_VENV_IN_PROJECT=1 \
PIPENV_IGNORE_VIRTUALENVS=1 \
pipenv install --clear --skip-lock --target=/app/.docker-venv # --target allows us to specify a different venv path so as not to conflict with .venv
ENV PATH="/app/.docker-venv/bin:${PATH}"
... This way the entire |
Any chance we can have this reopened and have this functionality tracked as a feature request? In addition, to all of this, it would be nice to be able to specify the target of the |
You can use the |
Sorry, I think what I wrote wasn't clear enough, I'm not looking for a custom
Ideally the former option |
Is raising a |
But then this won't add to the |
This worked for me on Windows 10, guessing it would work on other OSes.
|
As @pirate highlights ⬆️ Is there any possibility (in the current version) to specify where the venv folder should be? |
@nateprewitt (and the pipenv community) can you please reconsider adding a |
This is required to work in real world docker based deployment scenarios. Please re-open this. |
Thanks @AlJohri , this worked like a charm. |
For those trying to get it to work with Docker, you can set With respect to where does the files actually land, you can always rely on the good ol' symlynks right? Using those 2 I managed to set up a branch specific caching mechanism for my Flask project dependencies build by Jenkins multibranch within a Docker container, so I know it works in case the tip helps anybody |
This would be a very welcome feature. |
Just found this as well when looking for a solution and worked like a charm:
https://stackoverflow.com/questions/57919110/how-to-set-pipenv-venv-in-project-on-per-project-basis |
This works with a little bit of changes: |
We would love to have this feature too! |
Any change this is happening? I don't want my folder to be named |
Hi,
Could it be possible to create the virtualenv in the folder of our choice instead of
~/.local/share/virtualenvs/
?for example
which will create the venv in
~/fox_venv/projectA
and not in~/.local/share/virtualenvs/projectA-XdFl1243x
Regards
The text was updated successfully, but these errors were encountered: