Skip to content

Commit 1e66cbe

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 147484c commit 1e66cbe

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

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

Makefile

+13
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,16 @@ pip-dist-check:
4848
.PHONY: pip-dist-publish
4949
pip-dist-publish:
5050
twine upload -r testpypi -u __token__ -p ${PYPI_TOKEN} pip_dist/*
51+
52+
53+
.PHONY: rpm-dist
54+
rpm-dist:
55+
python3 setup.py sdist --dist-dir=rpm/SOURCES
56+
rpmbuild -ba --define "_topdir `pwd`/rpm" rpm/SPECS/python-tarantool.spec
57+
mkdir -p rpm_dist
58+
mv rpm/SRPMS/*.rpm -t rpm_dist
59+
mv rpm/RPMS/noarch/*.rpm -t rpm_dist
60+
61+
.PHONY: rpm-dist-check
62+
rpm-dist-check:
63+
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)