我正在尝试构建一个带有两个添加的 python3 版本的 RPM 包。我已经构建了一个使用
Rockylinux 8
附带 python3.6
的 Docker 容器。现在我添加了两个版本 3.9
和 3.11
使用:
dnf download --source python3.11-requests
rpm -ivh python3.11-requests-2.28.1-1.el8.src.rpm
和:
dnf download --source python39-requests
rpm -ivh python-requests-2.25.0-2.module+el8.8.0+1554+fb04b4e8.src.rpm
这是我正在使用的
.spec
文件,但如果我尝试构建它,它只会使用版本 3.11
构建它并忽略 3.9
:
%global underscore() %(echo %1 | sed 's/-/_/g')
%global sum A simple python library for interacting with the Messaging APP
%global desc A simple python library for interacting with the Messaging APP
Name: my-fake-library
Summary: %{sum}
Version: 0.6.1
Release: 1%{?dist}
Group: Development/Libraries
License: ASL 2.0
URL: https://github.com/fake-git/my-fake-library.git
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
%description
%{desc}
%define __python3 /usr/bin/python3.9
%define python3_pkgversion 3.9
%package -n python%{python3_pkgversion}-%{name}
Obsoletes: fake-library
Provides: fake-library
Summary: %{sum}
BuildRequires: python3-devel python3-setuptools
Requires: python3-requests
AutoReq: no
%description -n python%{python3_pkgversion}-%{name}
%{desc}
%{?python_provide:%python3_provide python3-%{name}}
%define __python3 /usr/bin/python3.11
%define python3_pkgversion 3.11
%package -n python%{python3_pkgversion}-%{name}
Summary: %{sum}
BuildRequires: python3-devel python3-setuptools
Requires: python3-requests
AutoReq: no
%description -n python%{python3_pkgversion}-%{name}
%{desc}
%{?python_provide:%python3_provide python3-%{name}}
%prep
%setup -q
%build
%{py3_build}
%install
rm -rf %{buildroot}
%{py3_install "--record=INSTALLED_FILES_PY39" }
%{py3_install "--record=INSTALLED_FILES_PY311" }
%files -n python%{python3_pkgversion}-%{name} -f INSTALLED_FILES_PY39
%doc examples/ README.md
%defattr(-,root,root,-)
%{python3_sitelib}/*
%files -n python%{python3_pkgversion}-%{name} -f INSTALLED_FILES_PY311
%doc examples/ README.md
%defattr(-,root,root,-)
%{python3_sitelib}/*
我做错了什么?谢谢!
我想我已经达到了我想要的。通过这个调整后的代码,我得到了两个 python3 包,其中包含我需要的版本,
python3-3.11-fake-library-0.6.1-1.el8.noarch.rpm
和python3-3.9-fake-library-0.6.1-1.el8.noarch.rpm
。
%global underscore() %(echo %1 | sed 's/-/_/g')
%global python3_pkgversion_1 3.9
%global python3_pkgversion_2 3.11
Name: fake-library
Summary: %{sum}
Version: 0.6.1
Release: 1%{?dist}
Group: Development/Libraries
License: ASL 2.0
URL: https://github.com/fake-git/my-fake-library.git
Source0: %{name}-%{version}.tar.gz
BuildArch: noarch
%description
%{desc}
%package -n python3-%{python3_pkgversion_1}-%{name}
Summary: %{sum}
BuildRequires: python39-devel python39-setuptools
Requires: python39-requests
AutoReq: no
%description -n python3-%{python3_pkgversion_1}-%{name}
%{desc}
%{?python_provide:%python_provide python3-%{python3_pkgversion_1}-%{name}}
%package -n python3-%{python3_pkgversion_2}-%{name}
Summary: %{sum}
BuildRequires: python3.11-devel python3.11-setuptools
Requires: python3.11-requests
AutoReq: no
%description -n python3-%{python3_pkgversion_2}-%{name}
%{desc}
%{?python_provide:%python_provide python3-%{python3_pkgversion_2}-%{name}}
%prep
%setup -q
%build
python3.9 setup.py build
python3.11 setup.py build
%install
rm -rf %{buildroot}
python3.9 setup.py install --root=%{buildroot} --record=INSTALLED_FILES_PY3_3.9
python3.11 setup.py install --root=%{buildroot} --record=INSTALLED_FILES_PY3_3.11
%files -n python3-%{python3_pkgversion_1}-%{name} -f INSTALLED_FILES_PY3_3.9
%doc examples/ README.md
%defattr(-,root,root,-)
/usr/lib/python3.9/site-packages/*
%files -n python3-%{python3_pkgversion_2}-%{name} -f INSTALLED_FILES_PY3_3.11
%doc examples/ README.md
%defattr(-,root,root,-)
/usr/lib/python3.11/site-packages/*