Skip to content

Commit 2fb5448

Browse files
cd: pack RPM package
New RPM spec is based on RHEL RPM guide for Python packages [1] merged with results of `python3 setup.py bdist_rpm --spec-only`. Beware that RPM name is changed based on recommendations for all mainstream distributives (for example, see [2]). Binary RPM is named python3-tarantool and source RPM is named python-tarantool. Before the patch they both were called tarantool-python (even though there wasn't new RPM releases since 0.6.5). RPM is suitable for distributives with Python 3.7 or newer. See [3] about pre-Python 3.7 systems support. 1. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages 2. https://fedoraproject.org/wiki/Packaging:Naming?rd=Packaging:NamingGuidelines#Python_source_package_naming 3. #257 Part of #164, #198
1 parent 2f8b46c commit 2fb5448

File tree

6 files changed

+150
-117
lines changed

6 files changed

+150
-117
lines changed

.github/workflows/packing.yml

+65
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,68 @@ jobs:
206206
env:
207207
PYPI_REPO: pypi
208208
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
209+
210+
pack_rpm:
211+
# We want to run on external PRs, but not on our own internal
212+
# PRs as they'll be run by the push to the branch.
213+
#
214+
# The main trick is described here:
215+
# https://github.com/Dart-Code/Dart-Code/pull/2375
216+
if: (github.event_name == 'push') ||
217+
(github.event_name == 'pull_request' &&
218+
github.event.pull_request.head.repo.full_name != github.repository)
219+
runs-on: ubuntu-latest
220+
221+
container:
222+
image: ${{ matrix.target.os }}:${{ matrix.target.dist }}
223+
224+
strategy:
225+
fail-fast: false
226+
227+
matrix:
228+
target:
229+
- os: fedora
230+
dist: '34'
231+
- os: fedora
232+
dist: '35'
233+
- os: fedora
234+
dist: '36'
235+
236+
steps:
237+
- name: Bump git version
238+
# Fails to compute package version inside docker otherwise:
239+
# https://github.com/actions/runner/issues/2033
240+
run: dnf install -y git
241+
242+
- name: Clone the connector repo
243+
uses: actions/checkout@v3
244+
# Checkout all tags for correct version computation.
245+
with:
246+
fetch-depth: 0
247+
248+
- name: Set ownership
249+
# Fails to compute package version inside docker otherwise:
250+
# https://github.com/actions/runner/issues/2033
251+
run: chown -R $(id -u):$(id -g) $PWD
252+
253+
- name: Setup Python and various packing tools
254+
run: dnf install -y python3 python3-libs python3-pip python3-setuptools python3-wheel
255+
256+
- name: Install RPM packing tools
257+
run: |
258+
dnf install -y gcc make coreutils diffutils patch
259+
dnf install -y rpm-build rpm-devel rpmlint rpmdevtools
260+
261+
- name: Pack source and binary RPM
262+
run: make rpm-dist
263+
264+
- name: Verify the package
265+
run: make rpm-dist-check
266+
267+
- name: Archive RPM artifacts
268+
uses: actions/upload-artifact@v3
269+
with:
270+
name: rpm_dist_${{ matrix.target.os }}_${{ matrix.target.dist }}
271+
path: rpm_dist
272+
retention-days: 1
273+
if-no-files-found: error

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,13 @@ venv/*
2222

2323
tarantool/version.py
2424
pip_dist
25+
26+
# Cannot ignore a directory and negate a single file
27+
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
28+
rpm/SOURCES
29+
rpm/SRPMS
30+
rpm/BUILDROOT
31+
rpm/BUILD
32+
rpm/RPMS
33+
34+
rpm_dist

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
187187
- Support iproto feature push (#201).
188188
- Pack pip package with GitHub Actions (#198).
189189
- Publish pip package with GitHub Actions (#198).
190+
- Pack RPM package with GitHub Actions (#164, #198).
190191

191192
### Changed
192193
- Bump msgpack requirement to 1.0.4 (PR #223).

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,16 @@ pip-dist: pip-sdist pip-bdist
4747
.PHONY: pip-dist-check
4848
pip-dist-check:
4949
twine check pip_dist/*
50+
51+
52+
.PHONY: rpm-dist
53+
rpm-dist:
54+
python3 setup.py sdist --dist-dir=rpm/SOURCES
55+
rpmbuild -ba --define "_topdir `pwd`/rpm" rpm/SPECS/python-tarantool.spec
56+
mkdir -p rpm_dist
57+
mv rpm/SRPMS/*.rpm -t rpm_dist
58+
mv rpm/RPMS/noarch/*.rpm -t rpm_dist
59+
60+
.PHONY: rpm-dist-check
61+
rpm-dist-check:
62+
rpm -K --nosignature rpm_dist/*.rpm

rpm/SPECS/python-tarantool.spec

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Based on https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/installing_and_using_dynamic_programming_languages/assembly_packaging-python-3-rpms_installing-and-using-dynamic-programming-languages
2+
# merged with python3 setup.py bdist_rpm --spec-only result.
3+
4+
%define srcname tarantool
5+
%define version %(python3 setup.py --version)
6+
7+
Name: python-%{srcname}
8+
Version: %{version}
9+
Release: 1%{?dist}
10+
Summary: Python client library for Tarantool
11+
12+
License: BSD
13+
Group: Development/Libraries
14+
URL: https://github.com/tarantool/tarantool-python
15+
16+
BuildArch: noarch
17+
Source: %{srcname}-%{version}.tar.gz
18+
Vendor: tarantool-python AUTHORS <[email protected]>
19+
20+
BuildRequires: python3-setuptools
21+
BuildRequires: python3-wheel
22+
23+
%global _description %{expand:
24+
Python client library for Tarantool.}
25+
26+
%description %_description
27+
28+
29+
%package -n python3-%{srcname}
30+
31+
Requires: python3-msgpack
32+
Requires: python3-pandas
33+
Requires: python3-pytz
34+
35+
Summary: %{summary}
36+
37+
Obsoletes: tarantool-python <= 0.9.0
38+
39+
%description -n python3-%{srcname} %_description
40+
41+
42+
%prep
43+
%setup -n %{srcname}-%{version}
44+
45+
46+
%build
47+
python3 setup.py build
48+
49+
50+
%install
51+
python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
52+
53+
54+
%clean
55+
rm -rf $RPM_BUILD_ROOT
56+
57+
58+
%files -n python3-%{srcname} -f INSTALLED_FILES
59+
60+
61+
%defattr(-,root,root)

rpm/tarantool-python.spec

-117
This file was deleted.

0 commit comments

Comments
 (0)