Convert from Fedora for the Python 3.12 stack in RHEL

Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
This commit is contained in:
Tomáš Hrnčiar 2023-10-20 14:16:00 +02:00 committed by Miro Hrončok
parent a9a75fbe0f
commit 30a96f7afa
4 changed files with 51 additions and 55 deletions

View File

@ -1,3 +0,0 @@
# python-setuptools-rust
The python-setuptools-rust package

View File

@ -1,25 +0,0 @@
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.12.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jun 02 2021 Python Maint <python-maint@redhat.com> - 0.12.1-2
- Rebuilt for Python 3.10
* Thu Mar 11 2021 Christian Heimes <cheimes@redhat.com> - 0.12.1-1
- Update to 0.12.1
* Tue Mar 09 2021 Christian Heimes <cheimes@redhat.com> - 0.12.0-1
- Update to 0.12.0 (#1936679)
- Run tomlgen example as test case
* Thu Feb 11 2021 Christian Heimes <cheimes@redhat.com> - 0.11.6-4
- Fix RHEL build: remove wheel build requirements, use rust-toolset
* Thu Feb 11 2021 Christian Heimes <cheimes@redhat.com> - 0.11.6-3
- Add RHEL packaging support
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.11.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Thu Jan 14 2021 Christian Heimes <cheimes@redhat.com> - 0.11.6-1
- Initial package.
- Resolves: rhbz#1906490

View File

@ -1,54 +1,65 @@
%global __python3 /usr/bin/python3.12
%global python3_pkgversion 3.12
# RHEL does not have packaged rust libraries
%bcond packaged_rust_libraries %{undefined rhel}
%bcond_with packaged_rust_libraries
# The integration tests depend on the presence of these libraries
%bcond integration_tests %{with packaged_rust_libraries}
%bcond_with integration_tests
# Regex of integration tests to skip.
# * html-py-ever requires unpackaged rust crates
%global integration_tests_exc '^(html-py-ever)'
Name: python-setuptools-rust
Name: python%{python3_pkgversion}-setuptools-rust
Version: 1.7.0
Release: %autorelease
Release: 1%{?dist}
Summary: Setuptools Rust extension plugin
License: MIT
URL: https://github.com/PyO3/setuptools-rust
Source0: %{pypi_source setuptools-rust}
Source1: setup.py
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: %{py3_dist pytest}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-rpm-macros
BuildRequires: python%{python3_pkgversion}-setuptools > 46.1
BuildRequires: python%{python3_pkgversion}-semantic_version >= 2.8.2
BuildRequires: python%{python3_pkgversion}-wheel
Requires: python%{python3_pkgversion}-semantic_version >= 2.8.2
Requires: python%{python3_pkgversion}-setuptools >= 62.4
%if 0%{?fedora}
BuildRequires: rust-packaging
Requires: rust-packaging
%else
# RHEL has rust-toolset instead of rust-packaging
BuildRequires: rust-toolset >= 1.45
Requires: rust-toolset >= 1.45
%endif
%if %{with integration_tests}
BuildRequires: %{py3_dist cffi}
%endif
%global _description %{expand:
%description
Setuptools helpers for Rust Python extensions. Compile and distribute Python
extensions written in Rust as easily as if they were written in C.}
%description %{_description}
%package -n python3-setuptools-rust
Summary: %{summary}
%if 0%{?fedora}
Requires: rust-packaging
%else
Requires: rust-toolset >= 1.45
%endif
%description -n python3-setuptools-rust %{_description}
%prep
%autosetup -n setuptools-rust-%{version}
# minimal setup.py to support %%py3_build and %%py3_install
cp %{SOURCE1} .
# remove dependency on typing-extensions and use stdlib instead
# python3.12-typing-extensions is not packaged in RHEL
sed -i '/typing_extensions/d' pyproject.toml
sed -i -e 's/typing_extensions/typing/' \
setuptools_rust/setuptools_ext.py \
setuptools_rust/build.py \
setuptools_rust/extension.py
%cargo_prep
@ -61,9 +72,8 @@ done
%endif
%generate_buildrequires
%pyproject_buildrequires
%if %{with integration_tests}
%generate_buildrequires
for example in $(ls examples/ | grep -vE %{integration_tests_exc}); do
cd "examples/${example}"
%cargo_generate_buildrequires
@ -73,16 +83,14 @@ done
%build
%pyproject_wheel
%py3_build
%install
%pyproject_install
%pyproject_save_files setuptools_rust
%py3_install
%check
%pyproject_check_import
# Disable tests that require internet access and/or test Windows functionality
%global test_ignores %{shrink:
not test_adjusted_local_rust_target_windows_msvc
@ -114,10 +122,20 @@ done
%endif
%files -n python3-setuptools-rust -f %{pyproject_files}
%files -n python%{python3_pkgversion}-setuptools-rust
%doc README.md CHANGELOG.md
%license LICENSE
%{python3_sitelib}/setuptools_rust/
%{python3_sitelib}/setuptools_rust-%{version}-py%{python3_version}.egg-info/
%changelog
%autochangelog
* Fri Oct 20 2023 Tomáš Hrnčiar <thrnciar@redhat.com> - 1.7.0-1
- Initial package
- Fedora contributions by:
Christian Heimes <cheimes@redhat.com>
Fabio Valentini <decathorpe@gmail.com>
Gwyn Ciesla <limb@fedoraproject.org>
Maxwell G <maxwell@gtmx.me>
Miro Hrončok <miro@hroncok.cz>
Tomáš Hrnčiar <thrnciar@redhat.com>

6
setup.py Normal file
View File

@ -0,0 +1,6 @@
# We need this for the build to work, but everything will be done
# by setuptools from pyproject.toml
from setuptools import setup
setup()