Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57861 > unrolled thread

Re: How do I update a virtualenv?

Started byNed Batchelder <ned@nedbatchelder.com>
First post2013-10-28 20:13 -0400
Last post2013-10-28 20:48 -0400
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How do I update a virtualenv? Ned Batchelder <ned@nedbatchelder.com> - 2013-10-28 20:13 -0400
    Re: How do I update a virtualenv? Roy Smith <roy@panix.com> - 2013-10-28 20:48 -0400

#57861 — Re: How do I update a virtualenv?

FromNed Batchelder <ned@nedbatchelder.com>
Date2013-10-28 20:13 -0400
SubjectRe: How do I update a virtualenv?
Message-ID<mailman.1731.1383006012.18130.python-list@python.org>
On 10/28/13 7:53 PM, Skip Montanaro wrote:
>> Virtualenvs aren't built to be moved from one Python installation to
>> another.  If you used pip to install your packages (you should), then you
>> can activate the virtualenv, and run: $ pip freeze > requirements.txt
>>
>> Then you can create a new virtualenv using the new Python executable,
>> activate it, and:  $ pip install -r requirements.txt
>>
>> This will reinstall all the packages you had installed previously. Even
>> better is to maintain your own requirements.txt that has just the packages
>> you need.  The "pip freeze" technique will also list packages installed as
>> dependencies.
> Hmmm... And my git repo?
Usually the virtualenv is outside the git repo (and vice-versa), but git 
repos are also easy to recreate from the git server if you need to.  
Maybe I don't understand what you mean?

> I imagine I will eventually figure this out,
> but updating an existing virtualenv in place to adapt to a new version
> of Python (say, a new micro) or some of its libraries (contents of
> requirements.txt) seems like it would be a very nice thing to have.

"pip install --upgrade" will upgrade your Python packages.  "pip install 
-r requirements.txt"  will install new packages or versions named in the 
requirements.txt file.

> Skip

--Ned.

[toc] | [next] | [standalone]


#57864

FromRoy Smith <roy@panix.com>
Date2013-10-28 20:48 -0400
Message-ID<roy-A0B43F.20481528102013@news.panix.com>
In reply to#57861
In article <mailman.1731.1383006012.18130.python-list@python.org>,
 Ned Batchelder <ned@nedbatchelder.com> wrote:

> "pip install --upgrade" will upgrade your Python packages.  "pip install 
> -r requirements.txt"  will install new packages or versions named in the 
> requirements.txt file.

Yup, that's what we do.  We've got a requirements.txt file that's 
checked into our source repo.  Part of our deployment process is to run 
"pip install -r requirements.txt".

You want to start doing this from day one on any new project.  One of 
the problems we had was we started not even using virtualenv.  When we 
switched to do that, we needed to come up with a list of what should be 
in it.  We started with "pip freeze", and got a list of all the crap we 
currently had installed.  We then needed to start sorting through it to 
figure out what we really needed and what was just excess baggage.  It's 
a lot cleaner if you start out doing it right at the beginning.

We build a fresh virtualenv on every code deployment.  This makes sure 
we know exactly what's in the virtualenv all the time.  It's a little 
extra work, but worth it.

We're looking at https://pypi.python.org/pypi/wheel to reduce deployment 
time.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web