Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to "version" my python distribution?

Tags:

python

I'm working by myself right now, but am looking at ways to scale my operation.

I'd like to find an easy way to version my Python distribution, so that I can recreate it very easily. Is there a tool to do this? Or can I add /usr/local/lib/python2.7/site-packages/ (or whatever) to an svn repo? This doesn't solve the problems with PATHs, but I can always write a script to alter the path. Ideally, the solution would be to build my Python env in a VM, and then hand copies of the VM out.

How have other people solved this?

like image 656
BenDundee Avatar asked Jan 24 '26 04:01

BenDundee


2 Answers

virtualenv + requirements.txt are your friend.

You can create several virtual python installs for your projects, everything containing exactly those library versions you need (Tip: pip freeze spits out a requirements.txt with the exact library versions).

Find a good reference to virtualenv here: http://simononsoftware.com/virtualenv-tutorial/ (it's from this question Comprehensive beginner's virtualenv tutorial?).

Alternatively, if you just want to distribute your code together with libraries, PyInstaller is worth a try. You can package everything together in a static executable - you don't even have to install the software afterwards.

like image 52
Gregor Avatar answered Jan 26 '26 18:01

Gregor


You want to use virtualenv. It lets you create an application(s) specific directory for installed packages. You can also use pip to generate and build a requirements.txt

like image 40
Jonathan Vanasco Avatar answered Jan 26 '26 17:01

Jonathan Vanasco



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!