Skip to content

Commit a129025

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 a129025

File tree

6 files changed

+142
-117
lines changed

6 files changed

+142
-117
lines changed

.github/workflows/packing.yml

+56
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,59 @@ 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: fedora:36
229+
230+
strategy:
231+
fail-fast: false
232+
233+
steps:
234+
- name: Bump git version
235+
# Fails to compute package version inside docker otherwise
236+
# https://github.com/actions/runner/issues/2033
237+
run: dnf install -y git-2.38.1
238+
239+
- name: Clone the connector repo
240+
uses: actions/checkout@v3
241+
# Checkout all tags for correct version computation
242+
with:
243+
fetch-depth: 0
244+
245+
- name: Set ownership
246+
# Fails to compute package version inside docker otherwise
247+
# https://github.com/actions/runner/issues/2033
248+
run: chown -R $(id -u):$(id -g) $PWD
249+
250+
- name: Setup Python and various packing tools
251+
run: dnf install -y python3 python3-libs python3-pip python3-setuptools python3-wheel
252+
253+
- name: Install RPM packing tools
254+
run: |
255+
dnf install -y gcc make coreutils diffutils patch
256+
dnf install -y rpm-build rpm-devel rpmlint rpmdevtools
257+
258+
- name: Pack source and binary RPM
259+
run: make rpm-dist
260+
261+
- name: Verify the package
262+
run: make rpm-dist-check
263+
264+
- name: Archive RPM artifacts
265+
uses: actions/upload-artifact@v3
266+
with:
267+
name: rpm_dist
268+
path: rpm_dist
269+
retention-days: 1
270+
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+
cp -r rpm/SRPMS/*.rpm -t rpm_dist
59+
cp -r 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

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

rpm/tarantool-python.spec

-117
This file was deleted.

0 commit comments

Comments
 (0)