Skip to content
Generate distribution packages from PyPI
Python OpenEdge ABL
Branch: master
Clone or download
Latest commit a060a31 Aug 6, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc Switch to pbr Feb 14, 2017
py2pack Merge pull request #105 from iyuroch/no-scripts-fix Aug 6, 2019
tools Allow packaging custom pypi names via Mar 2, 2017
.gitignore Switch to pbr Feb 14, 2017
.travis.yml Test python 3.6 and remove 3.5 Dec 22, 2017
README.rst Update repository name after move to openSUSE Aug 18, 2016
requirements.txt Require typing module for python < 3.5 Dec 14, 2018
setup.cfg Also support for python 3.6 Aug 7, 2017 Enable tests with python test Aug 7, 2017
test-requirements.txt Remove Sphinx cap Apr 21, 2018
tox.ini Ignore some more pep8 warnings Dec 6, 2018


Py2pack: Generate distribution packages from PyPI

This script allows to generate RPM spec or DEB dsc files from Python modules. It allows to list Python modules or search for them on the Python Package Index (PyPI). Conveniently, it can fetch tarballs and changelogs making it an universal tool to package Python modules.


To install py2pack from the Python Package Index, simply:

$ pip install py2pack

Or, if you absolutely must:

$ easy_install py2pack

But, you really shouldn't do that. Lastly, you can check your distro of choice if they provide packages. For openSUSE, you can find packages in the Open Build Service for all releases. If you happen to use openSUSE:Factory (the rolling release / development version), simply:

$ sudo zypper install python-py2pack


Lets suppose you want to package zope.interface and you don't know how it is named exactly. First of all, you can search for it and download the source tarball if you found the correct module:

$ py2pack search zope.interface
searching for module zope.interface...
found zope.interface-3.6.1
$ py2pack fetch zope.interface
downloading package zope.interface-3.6.1...

As a next step you may want to generate a package recipe for your distribution. For RPM-based distributions (let's use openSUSE as an example), you want to generate a spec file (named 'python-zope.interface.spec'):

$ py2pack generate zope.interface -t opensuse.spec -f python-zope.interface.spec

The source tarball and the package recipe is all you need to generate the RPM (or DEB) file. This final step may depend on which distribution you use. Again, for openSUSE (and by using the Open Build Service), the complete recipe is:

$ osc mkpac python-zope.interface
$ cd python-zope.interface
$ py2pack fetch zope.interface
$ py2pack generate zope.interface -f python-zope.interface.spec
$ osc build

Depending on the module, you may have to adapt the resulting spec file slightly. To get further help about py2pack usage, issue the following command:

$ py2pack help

Hacking and contributing

You can test py2pack from your git checkout by executing the py2pack module:

$ python -m py2pack

Fork the repository on Github to start making your changes to the master branch (or branch off of it). Don't forget to write a test for fixed issues or implemented features whenever appropriate. You can invoke the testsuite from the repository root directory via tox:

$ tox

To run a single test class via tox, use i.e.:

$ tox -epy27 test.test_py2pack:Py2packTestCase

You can also run nose directly:

$ nosetests

It assumes you have the test dependencies installed (available on PYTHONPATH) on your system.

  1. 2013 Sascha Peilicke.

Apache-2.0, see LICENSE for more details.

You can’t perform that action at this time.