Skip to main content
Py2pack: Generate distribution packages from PyPI
=================================================

.. image:: https://travis-ci.org/saschpe/py2pack.png?branch=master
:target: https://travis-ci.org/saschpe/py2pack


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.


Installation
------------

To install py2pack from the `Python Package Index`_, simply:

.. code-block:: bash

$ pip install py2pack

Or, if you absolutely must:

.. code-block:: bash

$ 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:

.. code-block:: bash

$ sudo zypper install python-py2pack


Usage
-----

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:

.. code-block:: bash

$ 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...
from http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.1.tar.gz


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'):

.. code-block:: bash

$ 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.

.. note:: The "generate" operation is parsing the setup.py and tries to extract
the needed information to generate a .spec file. That doesn't work in all cases.
There is a "--run" option (:code:`py2pack generate --run`) which may give better
results.

This final step may depend on which distribution you use. Again,
for openSUSE_ (and by using the `Open Build Service`_), the complete recipe is:

.. code-block:: bash

$ 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:

.. code-block:: bash

$ py2pack help


Hacking and contributing
------------------------

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

.. code-block:: bash

$ 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`_:

.. code-block:: bash

$ tox

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

.. code-block:: bash

$ tox -epy27 test.test_py2pack:Py2packTestCase


You can also run `nose`_ directly:

.. code-block:: bash

$ nosetests

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

:copyright: (c) 2013 Sascha Peilicke.
:license: Apache-2.0, see LICENSE for more details.


.. _argparse: http://pypi.python.org/pypi/argparse
.. _Jinja2: http://pypi.python.org/pypi/Jinja2
.. _zope.interface: http://pypi.python.org/pypi/zope.interface/
.. _openSUSE: http://www.opensuse.org/en/
.. _RPM: http://en.wikipedia.org/wiki/RPM_Package_Manager
.. _DEB: http://en.wikipedia.org/wiki/Deb_(file_format)
.. _`Python Package Index`: https://pypi.python.org/pypi/rapport
.. _`Open Build Service`: https://build.opensuse.org/package/show?package=rapport&project=devel:languages:python
.. _`the repository`: https://github.com/saschpe/py2pack
.. _`nose`: https://nose.readthedocs.org
.. _`tox`: http://testrun.org/tox

Release files for py2pack 0.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py2pack 0.6.1
File Size Uploaded
py2pack-0.6.1.tar.gz 28.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py2pack 0.6.1
File Interpreter ABI Platform
py2pack-0.6.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 65.3 kB

Release files / py2pack-0.6.1.tar.gz

Download URL py2pack-0.6.1.tar.gz
Size 28.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4cf1d1743c68fb43002951e8ee5a4dd70a261db287683adad6725df1fc65252e
BLAKE2b-256 checksum
How to use checksums
b6846a637c616e1ce86a3d605caf310de1135399e6ed6ce44e7507042afda702
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / py2pack-0.6.1-py2.py3-none-any.whl

Download URL py2pack-0.6.1-py2.py3-none-any.whl
Size 36.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
2374116949330743453040cc58b3175247e796ab713459f31ae305fca54a43b4
BLAKE2b-256 checksum
How to use checksums
14d78cc7ca24a6492ea08aa6f7044bf128ece7daf979b5e65232faa9c6d8d890
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.9.1

2 release files

0.9.0

2 release files

0.8.7

2 release files

0.8.6

1 release file

0.8.5

1 release file

0.8.4

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.7.0

1 release file

0.6.7

1 release file

0.6.6

1 release file

0.6.4

1 release file

0.6.3

2 release files

0.6.2

2 release files

This release

0.6.1 This release

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.9

2 release files

0.4.8

2 release files

0.4.6

3 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

3 release files

0.3.21

3 release files

0.3.20

3 release files

0.3.19

3 release files

0.3.18

3 release files

0.3.17

3 release files

0.3.15

3 release files

0.3.14

3 release files

0.3.11

3 release files

0.3.10

3 release files

0.3.9

3 release files

0.3.8

3 release files

0.3.7

3 release files

0.3.6

3 release files

0.3.5

3 release files

0.3.4

3 release files

0.3.3

3 release files

0.3.2

3 release files

0.3.1

3 release files

0.3.0

3 release files

0.2.12

3 release files

0.2.11

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page