-
-
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
multiple parallel environments #1071
Comments
For automated testing many people use a pipeline similar to what you would find in our Travis config file. However you also have the option to use your own virtualenv when running pipenv. Most people don’t handle this by hand but if you do you probably want to make your own virtualenv for each or use pyenv |
Thanks for the suggestion but deterministic virtualenv locations is an inherent part of what pipenv is, so I don't see us implementing this. I'm gonna close this out for now! |
Thanks for the answer.
I was mainly thinking about interactive use, i.e. debugging, or stuff that's hard to test automatically (GUI, look&feel).
location can still be deterministic, based on path+name, so there is no real conflict here.
Fair enough, thanks anyway! |
I also don't understand what conflict this would create with deterministic virtualenv locations. |
To be super clear, you can still get your own custom environments set up just by sourcing virtualenvs.
a tiny bit of additional visual clutter to the commands but is pretty straightforward |
Interesting, so if you run |
Yup |
The workaround kind of defeats the point of using pipenv... The argument about deterministic virtualenv locations is bunk, the python version would just be another factor in automatically selecting the correct virtualenv. I am not saying there isn't possibly some valid technical reason for rejecting this feature, but it would be nice to actually know what it is. |
@moloney Honest question out of curiosity: How would you design an interface if we are to start from the ground up for this one? How would you associate virtual environments to a given project without cluttering the usual workflow with I ask because I’ve been looking into building my own home-baked Pipfile + virtual environment tool, and collecting feedbacks for a while. Any feedback would help me greatly toward my goal. |
@uranusjr I should have been more precise. I agree that adding a I can understand not wanting to recreate the functionality of tox, but it is nice to be able to interactively switch between python versions and try things out without waiting for all the dependencies to reinstall. |
That makes sense. I’ll ponder on this a bit, and maybe I can even come up with a backward-compatible way to do this in Pipenv. |
Another use case for this is when I want to work on the same project in a shared folder used by different virtual machines. Currently I'm using the approach suggested by @jtratner. |
I have another use case: I'm working on a project with pytorch. The issue here is that the installation of pytorch is os specific, thus when I switch between linux and mac, the pytorch version is incompatible. So I was looking for a way to create an environment for each os. |
@uranusjr I realize this issue has been closed for some time now, but I'm wondering if there is any progress regarding a solution/feature? If so, would you please point me in the right direction? |
@nathanielcompton There is a (relatively recent) feature that adds support of an in-project # Initialize the project.
mkdir my-project
cd my-project
echo "" > Pipfile
# Create some environments.
python3.5 -m venv .venv-3.5 --prompt=my-project
python3.6 -m venv .venv-3.6 --prompt=my-project Now you can switch environments like this:
(Note: The So the functionality is there, all what’s left is to design a good UI around it. My suggestion would be to develop a standalone tool (called |
Hello @uranusjr, |
Windows is certainly an important reason behind this design, where symlinking is not viable in general. |
Hello all, Like @coldfix I am using pipenv for testing purposes. I tried @jtratner's solution, but then you use the same pipfile, while I had different requirements for my python 2.7 environment: an old wxPython version that is not pip installable. I found a solution involving the PIPENV_PIPFILE environment variable. I am sharing it here in the hope it can be useful to others. For the sake of this example let's say you are working under windows and your project folder is at: %USERPROFILE%\pythonprojects\project. Supposed that you need python 2.7 and 3.7 test environments, create subdirs 27 en 37 here. You need to put an initial Pipfile in these directories: they will not be created automatically. For switching environment I wrote the batch file activate.cmd and put it somewhere in my windows path. @if "%1"=="" (set PIPENV_PIPFILE=) else (set PIPENV_PIPFILE=%USERPROFILE%\pythonprojects\project\%1\Pipfile) Now you can install your virtual environments and start using them:
If you are using activate in a batch file, use If you need to use a Pipfile in the root of your project for distribution purposes, you can switch to that Pipfile by Cheers, Henk |
But this will always recreate the virtualenvs from scratch. |
Hi @amard33p, That is not correct. The first two command lines create a virtualenv per PIPENV_PIPFILE environment variable. So no need to repeat those steps every time you want to switch virtualenv. Actually the example demonstrates it. On the third and fourth line you switch back to PIPENV_PIPFILE 27 and 37 respectively. There is no recreation of the virtualenvs there. |
Hi,
thanks for this wonderful tool!! It's well crafted and extremely useful, but I feel that there is exactly one feature missing to make it just perfect for a workflow I frequently encounter while developing python packages:
One often needs to switch python versions in order to test behaviour on different python versions. Technically,
pipenv --python=XXX
can be used to switch between different python versions. However, this replaces the current environment and is therefore inconveniently slow in practice.I would really like to be able to install multiple environments in parallel for the same project and select which one to use on the
pipenv
command line. This can speed up the time required to switch python versions for the same project significantly and therefore we would have a powerful (IMO alround better) replacement for virtualenvwrapper and the like.This could work by e.g. providing an environment name on the command line:
One issue could be that of different lockfiles in different python versions..
If you would be fine with such an option and think that it is possible to implement for s.o. unacquainted with the code, I'm of course willing to help on the implementation.
This issue is related to #368 and #137 who I think were trying to ask the same question, but I'm unsure whether you rejected the idea altogether or were happy with an intermediate solution at the time.
Best, Thomas
The text was updated successfully, but these errors were encountered: