Live data from Hacker News

A non-magical introduction to pip and virtualenv for Python beginners

dabapps.com

1–10 of 86 posts

Re: A non-magical introduction to pip and virtualenv for Python beginners

#3
a good introduction - I would like to hear more about deployment with virtualenv though - is it expected that you just document any packages with requirements.txt and then you would create the virtualenv in the deployment target and set everything up again? Or can you "package" a virtualenv for deployment?

Re: A non-magical introduction to pip and virtualenv for Python beginners

#5

He mentions not checking the env directory into git. Why not? In general what are the best practices for using virtualenv with version control?

What if you want to perform a security update for one of the libraries on the server?

Also, IIRC the environment will contain a symlimk to the python executable and companion files. That symlink will change depending on the environment.

Re: A non-magical introduction to pip and virtualenv for Python beginners

#6

He mentions not checking the env directory into git. Why not? In general what are the best practices for using virtualenv with version control?

Keep your requirements file checked in, but not the virtualenv. The built env should be seen as disposable, and is both location (ie, path on disk) and platform (for libs which are not pure python) specific .

I keep my virtualenvs in ~/.virtualenvs/, away from the project.

Re: A non-magical introduction to pip and virtualenv for Python beginners

#7

He mentions not checking the env directory into git. Why not? In general what are the best practices for using virtualenv with version control?

You could have issues with other people not running the same version of python, also you might have different site packages if you are working on an experimental branch that will be pushed or merged later.

Re: A non-magical introduction to pip and virtualenv for Python beginners

#9
post #3

a good introduction - I would like to hear more about deployment with virtualenv though - is it expected that you just document any packages with requirements.txt and then you would create the virtualenv in the deployment target and set everything up again? Or can you "package" a virtualenv for deployment?

Just generate your requirements file from your env locally (pip freeze > requirements.txt), deploy all of your files (env folder excluded) to your sever however you want and then run 'env/bin/pip install -r requirements.txt' on your server.

Re: A non-magical introduction to pip and virtualenv for Python beginners

#10
post #3

a good introduction - I would like to hear more about deployment with virtualenv though - is it expected that you just document any packages with requirements.txt and then you would create the virtualenv in the deployment target and set everything up again? Or can you "package" a virtualenv for deployment?

[deleted]
Post reply on HN