GregB
GregB

Reputation: 5725

How do I make python requirements portable?

I am not a python pro, but python is really useful, so I'm trying to improve my skills.

I'm working on a project that uses 'requests' and 'grequests'. Both of these packages have dependencies, which are usually handled by 'pip' or 'easy_install'. This is fine for a development environment, or for installing to one or two machines, but I need to deploy my project to 200+ machines. What is the best way to package up my dependencies with my project so that it's portable?

python v2.7

Upvotes: 3

Views: 442

Answers (2)

Oleksii Kachaiev
Oleksii Kachaiev

Reputation: 6234

On your machine:

pip freeze > requirements.txt

On other machines:

pip install -r requirements.txt

Also, I advise you to look at virtualenv tool to work with dependencies in more comfortable way. For more sophisticated solutions (eg, distributed dependencies management), look at Puppet. Good presentation from PyCon: Dependency management with Puppet

Upvotes: 5

Martijn Pieters
Martijn Pieters

Reputation: 1121814

Use a requirements file for pip, or use a deployment tool like buildout, which supports complex installations and can pin versions for you:

[buildout]
versions = myversions
parts =
    mypackage

[myversions]
mypackage = 1.0
requests = ...

[mypackage]
recipe = zc.recipe.egg
eggs = mypackage

Upvotes: 1

Related Questions