|
| 1 | +Py2pack: Generate distribution packages from PyPI |
| 2 | +================================================= |
| 3 | + |
| 4 | +.. image:: https://github.com/huakim/lua2pack/actions/workflows/python-package.yml/badge.svg |
| 5 | + :target: https://github.com/huakim/lua2pack/actions/workflows/python-package.yml |
| 6 | + :alt: Unit tests |
| 7 | + |
| 8 | +This script allows to generate RPM spec files from luarocks. |
| 9 | + |
| 10 | + |
| 11 | +Installation |
| 12 | +------------ |
| 13 | + |
| 14 | +To install lua2pack from the `Python Package Index`_, simply: |
| 15 | + |
| 16 | +.. code-block:: bash |
| 17 | +
|
| 18 | + $ python3 -mpip install lua2pack |
| 19 | +
|
| 20 | +You can also check your distro of choice if they provide packages. |
| 21 | + |
| 22 | +Usage |
| 23 | +----- |
| 24 | + |
| 25 | +Lets suppose you want to package zope.interface_ and you don't know how it is named |
| 26 | +exactly. First of all, you can search for it and download the source tarball if |
| 27 | +you found the correct module: |
| 28 | + |
| 29 | +.. code-block:: bash |
| 30 | +
|
| 31 | + $ py2pack search zope.interface |
| 32 | + searching for module zope.interface... |
| 33 | + found zope.interface-3.6.1 |
| 34 | + $ py2pack fetch zope.interface |
| 35 | + downloading package zope.interface-3.6.1... |
| 36 | + from http://pypi.python.org/packages/source/z/zope.interface/zope.interface-3.6.1.tar.gz |
| 37 | +
|
| 38 | +
|
| 39 | +As a next step you may want to generate a package recipe for your distribution. |
| 40 | +For RPM_-based distributions (let's use openSUSE_ as an example), you want to |
| 41 | +generate a spec file (named 'python-zope.interface.spec'): |
| 42 | + |
| 43 | +.. code-block:: bash |
| 44 | +
|
| 45 | + $ py2pack generate zope.interface -t opensuse.spec -f python-zope.interface.spec |
| 46 | +
|
| 47 | +The source tarball and the package recipe is all you need to generate the RPM_ |
| 48 | +(or DEB_) file. |
| 49 | +This final step may depend on which distribution you use. Again, |
| 50 | +for openSUSE_ (and by using the `Open Build Service`_), the complete recipe is: |
| 51 | + |
| 52 | +.. code-block:: bash |
| 53 | +
|
| 54 | + $ osc mkpac python-zope.interface |
| 55 | + $ cd python-zope.interface |
| 56 | + $ py2pack fetch zope.interface |
| 57 | + $ py2pack generate zope.interface -f python-zope.interface.spec |
| 58 | + $ osc build |
| 59 | + ... |
| 60 | +
|
| 61 | +Depending on the module, you may have to adapt the resulting spec file slightly. |
| 62 | +To get further help about py2pack usage, issue the following command: |
| 63 | + |
| 64 | +.. code-block:: bash |
| 65 | +
|
| 66 | + $ py2pack help |
| 67 | +
|
| 68 | +
|
| 69 | +Hacking and contributing |
| 70 | +------------------------ |
| 71 | + |
| 72 | +You can test py2pack from your git checkout by executing the py2pack module. |
| 73 | + |
| 74 | +Edit `py2pack/version.py` file changing the version number. Adding +1 to the revision |
| 75 | +number and optionally appending .dev1 is enough and makes sure that you can |
| 76 | +distinguish your hackish version from an installed one. |
| 77 | + |
| 78 | +From the py2pack directory, install the py2pack module locally. |
| 79 | + |
| 80 | +.. code-block:: bash |
| 81 | +
|
| 82 | + $ pip install -e . |
| 83 | +
|
| 84 | +Now you can run your hackish py2pack version. It is usually located in |
| 85 | +$HOME/.local/bin/py2pack |
| 86 | + |
| 87 | +.. code-block:: bash |
| 88 | +
|
| 89 | + $ py2pack |
| 90 | +
|
| 91 | +Fork `the repository`_ on Github to start making your changes to the **master** |
| 92 | +branch (or branch off of it). Don't forget to write a test for fixed issues or |
| 93 | +implemented features whenever appropriate. You can invoke the testsuite from |
| 94 | +the repository root directory via `tox`_: |
| 95 | + |
| 96 | +.. code-block:: bash |
| 97 | +
|
| 98 | + $ tox |
| 99 | +
|
| 100 | +To run a single test class via `tox`_, use i.e.: |
| 101 | + |
| 102 | +.. code-block:: bash |
| 103 | +
|
| 104 | + $ tox -epy38 test.test_py2pack:Py2packTestCase |
| 105 | +
|
| 106 | +
|
| 107 | +You can also run `pytest`_ directly: |
| 108 | + |
| 109 | +.. code-block:: bash |
| 110 | +
|
| 111 | + $ pytest |
| 112 | +
|
| 113 | +It assumes you have the test dependencies installed (available on PYTHONPATH) |
| 114 | +on your system. |
| 115 | + |
| 116 | +:copyright: (c) 2013 Sascha Peilicke. |
| 117 | +:license: Apache-2.0, see LICENSE for more details. |
| 118 | + |
| 119 | + |
| 120 | +.. _argparse: http://pypi.python.org/pypi/argparse |
| 121 | +.. _Jinja2: http://pypi.python.org/pypi/Jinja2 |
| 122 | +.. _zope.interface: http://pypi.python.org/pypi/zope.interface/ |
| 123 | +.. _openSUSE: http://www.opensuse.org/en/ |
| 124 | +.. _RPM: http://en.wikipedia.org/wiki/RPM_Package_Manager |
| 125 | +.. _DEB: http://en.wikipedia.org/wiki/Deb_(file_format) |
| 126 | +.. _`Python Package Index`: https://pypi.org/ |
| 127 | +.. _`Open Build Service`: https://build.opensuse.org/package/show/devel:languages:python/python-py2pack |
| 128 | +.. _`the repository`: https://github.com/openSUSE/py2pack |
| 129 | +.. _`pytest`: https://github.com/pytest-dev/pytest |
| 130 | +.. _`tox`: http://testrun.org/tox |
0 commit comments