Python packages distribution

Currently python options for code distribution  are bit messy as described here.   I spent some time to find right way how to create setup script, which will install external dependencies,   so here is the recipe for python3:

Create virtual virtual environment for your project:

virtualenv -p /usr/bin/python3 .

Then create setup.py file – two important things:

Import setup function from setuptools,   this l enables to specify dependencies, which should be installed  automatically by pip or easy_setup.

It is important that install_requires keyword is  included. Also note different syntax of version requirements  – requires vs install_requires . (requires and provides are probably not necessary ).

Test files,  readme, license  files etc.   specify them in MANIFEST.in file in root of distribution – something like this:

Once all code is ready you can create distribution with command:

python setup.py sdist

This will create packed distribution in dist subdirectory  and then you can try to install in another virtual environment by:

pip install path/to/dist/packageX-1.0.0.tar.gz

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">