Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #52253 > unrolled thread
| Started by | Luca Cerone <luca.cerone@gmail.com> |
|---|---|
| First post | 2013-08-09 01:29 -0700 |
| Last post | 2013-08-16 01:35 -0700 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.python
"Nested" virtual environments Luca Cerone <luca.cerone@gmail.com> - 2013-08-09 01:29 -0700
Re: "Nested" virtual environments Marcel Rodrigues <marcelgmr@gmail.com> - 2013-08-15 13:30 -0300
Re: "Nested" virtual environments Luca Cerone <luca.cerone@gmail.com> - 2013-08-16 01:35 -0700
| From | Luca Cerone <luca.cerone@gmail.com> |
|---|---|
| Date | 2013-08-09 01:29 -0700 |
| Subject | "Nested" virtual environments |
| Message-ID | <18c0a8bb-9295-493b-b0aa-1593b7d05c2f@googlegroups.com> |
Dear all, is there a way to "nest" virtual environments? I work on several different projects that involve Python programming. For a lot of this projects I have to use the same packages (e.g. numpy, scipy, matplotlib and so on), while having to install packages that are specific for each project. For each of this project I created a virtual environment (using virtualenv --no-site-packages) and I had to reinstall the shared packages in each of them. I was wondering if there is a way to nest a virtual environment into another, so that I can create a "common" virtual environment that contains all the shared packages and then "specialize" the virtual environments installing the packages specific for each project. In a way this is not conceptually different to using virtualenv --system-site-packages, just instead of getting access to the system packages a virtual environment should be able to access the packages of an other one. Thanks a lot in advance for the help, Luca
[toc] | [next] | [standalone]
| From | Marcel Rodrigues <marcelgmr@gmail.com> |
|---|---|
| Date | 2013-08-15 13:30 -0300 |
| Message-ID | <mailman.603.1376584227.1251.python-list@python.org> |
| In reply to | #52253 |
[Multipart message — attachments visible in raw view] — view raw
I don't know how to completely solve this problem, but here is something that can alleviate it considerably. If you have a recent version of pip, you can use wheels [1] to save built packages locally. First create a new virtualenv and install the common packages. Then put these packages in a wheel directory. Then, for any other virtualenv that need the common packages, you can easily install then from the wheel directory (this is fast even for numpy & friends, because nothing will be compiled again) [2]. # Create a new virtualenv virtualenv myenv source myenv/bin/activate # Install the wheel package pip install wheel # Install your common packages pip install numpy scipy matplotlib # Create a requirements file pip freeze > /local/requirements.txt # Create wheel for the common packages pip wheel --wheel-dir=/local/wheels -r /local/requirements.txt Now you have all the built packages saved to /local/wheels, ready to install on any other environment. You can safely delete myenv. Test it with the following: # Create a virtualenv for a new project virtualenv myproj source myproj/bin/activate # Install common packages from wheel pip install --use-wheel --no-index --find-links=/local/wheels -r /local/requirements.txt [1] https://wheel.readthedocs.org [2] http://www.pip-installer.org/en/latest/cookbook.html#building-and-installing-wheels 2013/8/9 Luca Cerone <luca.cerone@gmail.com> > Dear all, is there a way to "nest" virtual environments? > > I work on several different projects that involve Python programming. > > For a lot of this projects I have to use the same packages (e.g. numpy, > scipy, matplotlib and so on), while having to install packages that are > specific > for each project. > > For each of this project I created a virtual environment (using virtualenv > --no-site-packages) and I had to reinstall the shared packages in each of > them. > > I was wondering if there is a way to nest a virtual environment into > another, > so that I can create a "common" virtual environment that contains all the > shared packages and then "specialize" the virtual environments installing > the packages specific for each project. > > In a way this is not conceptually different to using virtualenv > --system-site-packages, just instead of getting access to the system > packages a virtual environment should be able to access the packages of an > other one. > > Thanks a lot in advance for the help, > Luca > -- > http://mail.python.org/mailman/listinfo/python-list >
[toc] | [prev] | [next] | [standalone]
| From | Luca Cerone <luca.cerone@gmail.com> |
|---|---|
| Date | 2013-08-16 01:35 -0700 |
| Message-ID | <cc5504bf-a518-4dde-aeaa-77f2535b85e1@googlegroups.com> |
| In reply to | #52558 |
Thanks Marcel, I will give it a try during the weekend and let you know if it worked for me :) > > If you have a recent version of pip, you can use wheels [1] to save built packages locally. First create a new virtualenv and install the common packages. Then put these packages in a wheel directory. Then, for any other virtualenv that need the common packages, you can easily install then from the wheel directory (this is fast even for numpy & friends, because nothing will be compiled again) [2]. > > > > # Create a new virtualenv > > virtualenv myenv > > source myenv/bin/activate > # Install the wheel package > pip install wheel > # Install your common packages > > pip install numpy scipy matplotlib > # Create a requirements file > pip freeze > /local/requirements.txt > # Create wheel for the common packages > pip wheel --wheel-dir=/local/wheels -r /local/requirements.txt > > > Now you have all the built packages saved to /local/wheels, ready to install on any other environment. You can safely delete myenv. Test it with the following: > > # Create a virtualenv for a new project > > virtualenv myproj > source myproj/bin/activate > # Install common packages from wheel > pip install --use-wheel --no-index --find-links=/local/wheels -r /local/requirements.txt > > > > > > > > > > > > > > [1] https://wheel.readthedocs.org > [2] http://www.pip-installer.org/en/latest/cookbook.html#building-and-installing-wheels > > > > > > > 2013/8/9 Luca Cerone <luca....@gmail.com> > > Dear all, is there a way to "nest" virtual environments? > > > > I work on several different projects that involve Python programming. > > > > For a lot of this projects I have to use the same packages (e.g. numpy, scipy, matplotlib and so on), while having to install packages that are specific > > for each project. > > > > For each of this project I created a virtual environment (using virtualenv --no-site-packages) and I had to reinstall the shared packages in each of them. > > > > I was wondering if there is a way to nest a virtual environment into another, > > so that I can create a "common" virtual environment that contains all the > > shared packages and then "specialize" the virtual environments installing the packages specific for each project. > > > > In a way this is not conceptually different to using virtualenv --system-site-packages, just instead of getting access to the system packages a virtual environment should be able to access the packages of an other one. > > > > > Thanks a lot in advance for the help, > > Luca > > -- > > http://mail.python.org/mailman/listinfo/python-list
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web