There are several ways to ship a python application but the most straight-forward method is to either package it (as a pip package) or pip freeze
it's dependencies and share the code.
Read here for more
pip freeze
will produce a similar list of the installed packages, but the output uses the format that pip install expects. A common convention is to put this list in a requirements.txt
file:
(tutorial-env) $ pip freeze > requirements.txt
(tutorial-env) $ cat requirements.txt
novas==3.1.1.3
numpy==1.9.2
requests==2.7.0
The requirements.txt
can then be committed to version control and shipped as part of an application. Users can then install all the necessary packages with install -r
:
(tutorial-env) $ python -m pip install -r requirements.txt
Collecting novas==3.1.1.3 (from -r requirements.txt (line 1))
...
Collecting numpy==1.9.2 (from -r requirements.txt (line 2))
...
Collecting requests==2.7.0 (from -r requirements.txt (line 3))
...
Installing collected packages: novas, numpy, requests
Running setup.py install for novas
Successfully installed novas-3.1.1.3 numpy-1.9.2 requests-2.7.0
One alternative worth mentioning is to containerize your application (using docker or similar technology) and share it. This would help address the common "works on my machine" issue.
Containerized Python Development