Skip to content

Commit 9877d0b

Browse files
cd: build rpm package
New RPM spec is based on RHEL RPM guide for Python packages [1] merged with results of deprecated `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). 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
1 parent 2828e02 commit 9877d0b

File tree

5 files changed

+144
-118
lines changed

5 files changed

+144
-118
lines changed

.github/workflows/packing.yml

+52
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,58 @@ jobs:
5555
path: dist
5656
retention-days: 1
5757

58+
pack_rpm:
59+
# We want to run on external PRs, but not on our own internal
60+
# PRs as they'll be run by the push to the branch.
61+
#
62+
# The main trick is described here:
63+
# https://github.com/Dart-Code/Dart-Code/pull/2375
64+
if: (github.event_name == 'push') ||
65+
(github.event_name == 'pull_request' &&
66+
github.event.pull_request.head.repo.full_name != github.repository)
67+
runs-on: ubuntu-20.04
68+
69+
container:
70+
image: fedora:36
71+
72+
strategy:
73+
fail-fast: false
74+
75+
steps:
76+
- name: Bump git version
77+
# Fails to compute package version inside docker otherwise
78+
# https://github.com/actions/runner/issues/2033
79+
run: dnf install -y git-2.38.1
80+
81+
- name: Clone the connector repo
82+
uses: actions/checkout@v3
83+
# Checkout all tags for correct version computation
84+
with:
85+
fetch-depth: 0
86+
87+
- name: Set ownership
88+
# Fails to compute package version inside docker otherwise
89+
# https://github.com/actions/runner/issues/2033
90+
run: chown -R $(id -u):$(id -g) $PWD
91+
92+
- name: Setup Python and Python packing tools
93+
run: dnf install -y python3 python3-libs python3-pip python3-setuptools python3-wheel
94+
95+
- name: Install rpm packing tools
96+
run: dnf install -y gcc rpm-build rpm-devel rpmlint make bash coreutils diffutils patch rpmdevtools
97+
98+
- name: Pack rpm
99+
run: make rpm
100+
101+
- name: Archive rpm artifacts
102+
uses: actions/upload-artifact@v3
103+
with:
104+
name: package_rpm
105+
path: |
106+
rpm/RPMS
107+
rpm/SRPMS
108+
retention-days: 1
109+
58110
run_tests_pip_package_install_linux:
59111
needs: pack_pip
60112

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ sophia
2121
venv/*
2222

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

Makefile

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: install test docs sdist wheel
1+
.PHONY: install test docs sdist wheel sdist-rpm rpm
22
install:
33
pip install --editable .
44
test:
@@ -17,3 +17,10 @@ sdist:
1717
python3 setup.py sdist --dist-dir=dist
1818
wheel:
1919
python3 setup.py bdist_wheel --dist-dir=dist
20+
sdist-rpm:
21+
python3 setup.py sdist --dist-dir rpm/SOURCES
22+
rpm: sdist-rpm
23+
rpmbuild -ba \
24+
--define "_topdir `pwd`/rpm" \
25+
--define='_version '$$(python3 setup.py --version) \
26+
rpm/SPECS/python-tarantool.spec

rpm/SPECS/python-tarantool.spec

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
Obsoletes: tarantool-python <= 0.9.0
18+
19+
BuildArch: noarch
20+
Source: %{srcname}-%{version}.tar.gz
21+
Vendor: tarantool-python AUTHORS <[email protected]>
22+
23+
BuildRequires: python3-setuptools
24+
BuildRequires: python3-wheel
25+
BuildRequires: python3-wheel
26+
27+
Requires: python3-msgpack
28+
Requires: python3-pandas
29+
Requires: python3-pytz
30+
31+
%global _description %{expand:
32+
Python client library for Tarantool.}
33+
34+
%description %_description
35+
36+
37+
%package -n python36-%{srcname}
38+
39+
Requires: python3-dataclasses
40+
41+
Summary: %{summary}
42+
43+
%description -n python36-%{srcname} %_description
44+
45+
46+
%package -n python3-%{srcname}
47+
Summary: %{summary}
48+
49+
Obsoletes: python36-tarantool <= %{version}
50+
51+
%description -n python3-%{srcname} %_description
52+
53+
54+
55+
56+
%prep
57+
%setup -n %{srcname}-%{version}
58+
59+
60+
%build
61+
python3 setup.py build
62+
63+
64+
%install
65+
python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES
66+
67+
68+
%clean
69+
rm -rf $RPM_BUILD_ROOT
70+
71+
72+
%files -n python36-%{srcname} -f INSTALLED_FILES
73+
%files -n python3-%{srcname} -f INSTALLED_FILES
74+
75+
76+
%defattr(-,root,root)

rpm/tarantool-python.spec

-117
This file was deleted.

0 commit comments

Comments
 (0)