Skip to content

Commit 9f65688

Browse files
author
u
committed
update
1 parent afffea5 commit 9f65688

4 files changed

Lines changed: 169 additions & 3 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Unit tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
fail-fast: false
10+
matrix:
11+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14.0-alpha.4"]
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install tox
20+
run: python -m pip install --upgrade pip tox tox-gh-actions
21+
- name: Run the test suite
22+
run: python -m tox --parallel auto --parallel-live -- -vvvvv
23+
24+
lint:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Set up Python 3.13
29+
uses: actions/setup-python@v5
30+
with:
31+
python-version: "3.13"
32+
- name: Install tox
33+
run: python -m pip install --upgrade pip tox
34+
- name: Lint
35+
run: tox -e pep8

README.rst

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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

lua2pack/templates/generic.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ echo {{ add_check_requires[dep] }}
188188
%if %{defined luarocks_pkg_build}
189189
%luarocks_pkg_build %{lua_version}
190190
%else
191-
%luarocks_build --local %{SOURCE1}
191+
%luarocks_build %{SOURCE1}
192192
%endif
193193
{%- if subpackages %}
194194
%endif

test_spec_content.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
%define luarocks_pkg_prefix lua-cjson-2.1.0.11-1
44
%define luarocks_pkg_major 2.1.0.11
55
%define luarocks_pkg_minor 1
6+
%{?!luadist:%define luadist(-) lua}
67

78
Name: lua-cjson
89
Version: %{luarocks_pkg_major}
@@ -13,7 +14,7 @@ License: MIT
1314
Source0: lua-cjson-2.1.0.11-1.tar.gz
1415
Source1: lua-cjson-2.1.0.11-1.rockspec
1516
BuildRequires: lua-rpm-macros
16-
BuildRequires: luarock-macros
17+
BuildRequires: luarocks-macros
1718
Requires(postun): alternatives
1819
Requires(post): alternatives
1920
Provides: %{luadist %{luarocks_pkg_name} = %{luarocks_pkg_version}}
@@ -42,7 +43,7 @@ Provides: luadist(%{luarocks_pkg_name}) = %{luarocks_pkg_version}
4243
%if %{defined luarocks_pkg_build}
4344
%luarocks_pkg_build %{lua_version}
4445
%else
45-
%luarocks_build --local
46+
%luarocks_build --local %{SOURCE1}
4647
%endif
4748

4849
%install

0 commit comments

Comments
 (0)