Skip to main content

Generate distribution packages from PyPI

Project description

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-hypernode.com/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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py2pack-0.6.2.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

py2pack-0.6.2-py2.py3-none-any.whl (37.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file py2pack-0.6.2.tar.gz.

File metadata

  • Download URL: py2pack-0.6.2.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for py2pack-0.6.2.tar.gz
Algorithm Hash digest
SHA256 75974af9bbd9261e3a687c70a77b198105450cd71085c7b06c63d62fb65cc0c8
MD5 6f0ccfff738741483e246cdb2d852243
BLAKE2b-256 5b53d426032e89b77903959398592c96f2698f2ad7b08d2d4be79ba28481fdca

See more details on using hashes here.

File details

Details for the file py2pack-0.6.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for py2pack-0.6.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 14d4407f12e1a311a274a146194c3a3892cef5af27e4003812818d953051d1d6
MD5 669343c737795d2b76e4f8de6f9d8ca8
BLAKE2b-256 65db9574622f8ad50d3599e08a2e3a7c3b00e1c16528dd62b31c2bce06477905

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page