Skip to content

Commit

Permalink
cd: pack RPM package
Browse files Browse the repository at this point in the history
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
  • Loading branch information
DifferentialOrange committed Nov 9, 2022
1 parent 2f8b46c commit 2fb5448
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 117 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/packing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,68 @@ jobs:
env:
PYPI_REPO: pypi
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}

pack_rpm:
# We want to run on external PRs, but not on our own internal
# PRs as they'll be run by the push to the branch.
#
# The main trick is described here:
# https://github.com/Dart-Code/Dart-Code/pull/2375
if: (github.event_name == 'push') ||
(github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name != github.repository)
runs-on: ubuntu-latest

container:
image: ${{ matrix.target.os }}:${{ matrix.target.dist }}

strategy:
fail-fast: false

matrix:
target:
- os: fedora
dist: '34'
- os: fedora
dist: '35'
- os: fedora
dist: '36'

steps:
- name: Bump git version
# Fails to compute package version inside docker otherwise:
# https://github.com/actions/runner/issues/2033
run: dnf install -y git

- name: Clone the connector repo
uses: actions/checkout@v3
# Checkout all tags for correct version computation.
with:
fetch-depth: 0

- name: Set ownership
# Fails to compute package version inside docker otherwise:
# https://github.com/actions/runner/issues/2033
run: chown -R $(id -u):$(id -g) $PWD

- name: Setup Python and various packing tools
run: dnf install -y python3 python3-libs python3-pip python3-setuptools python3-wheel

- name: Install RPM packing tools
run: |
dnf install -y gcc make coreutils diffutils patch
dnf install -y rpm-build rpm-devel rpmlint rpmdevtools
- name: Pack source and binary RPM
run: make rpm-dist

- name: Verify the package
run: make rpm-dist-check

- name: Archive RPM artifacts
uses: actions/upload-artifact@v3
with:
name: rpm_dist_${{ matrix.target.os }}_${{ matrix.target.dist }}
path: rpm_dist
retention-days: 1
if-no-files-found: error
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ venv/*

tarantool/version.py
pip_dist

# Cannot ignore a directory and negate a single file
# https://www.atlassian.com/git/tutorials/saving-changes/gitignore
rpm/SOURCES
rpm/SRPMS
rpm/BUILDROOT
rpm/BUILD
rpm/RPMS

rpm_dist
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support iproto feature push (#201).
- Pack pip package with GitHub Actions (#198).
- Publish pip package with GitHub Actions (#198).
- Pack RPM package with GitHub Actions (#164, #198).

### Changed
- Bump msgpack requirement to 1.0.4 (PR #223).
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ pip-dist: pip-sdist pip-bdist
.PHONY: pip-dist-check
pip-dist-check:
twine check pip_dist/*


.PHONY: rpm-dist
rpm-dist:
python3 setup.py sdist --dist-dir=rpm/SOURCES
rpmbuild -ba --define "_topdir `pwd`/rpm" rpm/SPECS/python-tarantool.spec
mkdir -p rpm_dist
mv rpm/SRPMS/*.rpm -t rpm_dist
mv rpm/RPMS/noarch/*.rpm -t rpm_dist

.PHONY: rpm-dist-check
rpm-dist-check:
rpm -K --nosignature rpm_dist/*.rpm
61 changes: 61 additions & 0 deletions rpm/SPECS/python-tarantool.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# 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
# merged with python3 setup.py bdist_rpm --spec-only result.

%define srcname tarantool
%define version %(python3 setup.py --version)

Name: python-%{srcname}
Version: %{version}
Release: 1%{?dist}
Summary: Python client library for Tarantool

License: BSD
Group: Development/Libraries
URL: https://github.com/tarantool/tarantool-python

BuildArch: noarch
Source: %{srcname}-%{version}.tar.gz
Vendor: tarantool-python AUTHORS <[email protected]>

BuildRequires: python3-setuptools
BuildRequires: python3-wheel

%global _description %{expand:
Python client library for Tarantool.}

%description %_description


%package -n python3-%{srcname}

Requires: python3-msgpack
Requires: python3-pandas
Requires: python3-pytz

Summary: %{summary}

Obsoletes: tarantool-python <= 0.9.0

%description -n python3-%{srcname} %_description


%prep
%setup -n %{srcname}-%{version}


%build
python3 setup.py build


%install
python3 setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES


%clean
rm -rf $RPM_BUILD_ROOT


%files -n python3-%{srcname} -f INSTALLED_FILES


%defattr(-,root,root)
117 changes: 0 additions & 117 deletions rpm/tarantool-python.spec

This file was deleted.

0 comments on commit 2fb5448

Please sign in to comment.