Handle flit_core migration and bootstrapping
wheel now uses flit_core as its build backend. We can't use %py3_build or %py3_install anymore, as there is no setup.py. This commit reworks the bootstrap logic accordingly. The build process requires building a wheel anyways, so python3-wheel-wheel is always built. When bootstrapping, neither pip and thus pyproject-rpm-macros is not available so the following workarounds are employed: - Build wheel using `%python3 -m flit_core.wheel` instead of %pyproject_wheel which requires pip - Manually unpack wheel and create entrypoints instead of %pyproject_install which requires pip.
This commit is contained in:
parent
995a27f40b
commit
1d3028140f
@ -26,17 +26,25 @@ Summary: Built-package format for Python
|
|||||||
License: MIT and (ASL 2.0 or BSD)
|
License: MIT and (ASL 2.0 or BSD)
|
||||||
URL: https://github.com/pypa/wheel
|
URL: https://github.com/pypa/wheel
|
||||||
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
|
Source0: %{url}/archive/%{version}/%{pypi_name}-%{version}.tar.gz
|
||||||
|
# This is used in bootstrap mode where we manually install the wheel and
|
||||||
|
# entrypoints
|
||||||
|
Source1: wheel-entrypoint
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
BuildRequires: python%{python3_pkgversion}-devel
|
BuildRequires: python%{python3_pkgversion}-devel
|
||||||
BuildRequires: python%{python3_pkgversion}-setuptools
|
|
||||||
|
|
||||||
# python3 bootstrap: this is rebuilt before the final build of python3, which
|
# python3 bootstrap: this is rebuilt before the final build of python3, which
|
||||||
# adds the dependency on python3-rpm-generators, so we require it manually
|
# adds the dependency on python3-rpm-generators, so we require it manually
|
||||||
BuildRequires: python3-rpm-generators
|
BuildRequires: python3-rpm-generators
|
||||||
|
|
||||||
|
# Needed to manually build and unpack the wheel
|
||||||
|
%if %{with bootstrap}
|
||||||
|
BuildRequires: python%{python3_pkgversion}-flit-core
|
||||||
|
BuildRequires: unzip
|
||||||
|
%endif
|
||||||
|
|
||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
BuildRequires: python%{python3_pkgversion}-pytest
|
BuildRequires: python%{python3_pkgversion}-pytest
|
||||||
|
BuildRequires: python%{python3_pkgversion}-setuptools
|
||||||
# several tests compile extensions
|
# several tests compile extensions
|
||||||
# those tests are skipped if gcc is not found
|
# those tests are skipped if gcc is not found
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@ -69,44 +77,62 @@ Summary: %{summary}
|
|||||||
%description -n python%{python3_pkgversion}-%{pypi_name} %{_description}
|
%description -n python%{python3_pkgversion}-%{pypi_name} %{_description}
|
||||||
|
|
||||||
|
|
||||||
%if %{without bootstrap}
|
|
||||||
%package -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
%package -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
||||||
Summary: The Python wheel module packaged as a wheel
|
Summary: The Python wheel module packaged as a wheel
|
||||||
%{bundled}
|
%{bundled}
|
||||||
|
|
||||||
%description -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
%description -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
||||||
A Python wheel of wheel to use with virtualenv.
|
A Python wheel of wheel to use with virtualenv.
|
||||||
%endif
|
|
||||||
|
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{pypi_name}-%{version} -p1
|
%autosetup -n %{pypi_name}-%{version} -p1
|
||||||
|
|
||||||
|
|
||||||
|
%if %{without bootstrap}
|
||||||
|
%generate_buildrequires
|
||||||
|
%pyproject_buildrequires
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%py3_build
|
%if %{with bootstrap}
|
||||||
|
%global _pyproject_wheeldir dist
|
||||||
|
%python3 -m flit_core.wheel
|
||||||
|
%else
|
||||||
|
%pyproject_wheel
|
||||||
|
%endif
|
||||||
|
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%py3_install
|
# pip is not available when bootstrapping, so we need to unpack the wheel and
|
||||||
|
# create the entrypoints manually.
|
||||||
|
%if %{with bootstrap}
|
||||||
|
mkdir -p %{buildroot}%{python3_sitelib}
|
||||||
|
unzip %{_pyproject_wheeldir}/%{python_wheel_name} \
|
||||||
|
-d %{buildroot}%{python3_sitelib} -x wheel-%{version}.dist-info/RECORD
|
||||||
|
install -Dpm 0755 %{SOURCE1} %{buildroot}%{_bindir}/wheel
|
||||||
|
%py3_shebang_fix %{buildroot}%{_bindir}/wheel
|
||||||
|
%else
|
||||||
|
%pyproject_install
|
||||||
|
%endif
|
||||||
|
|
||||||
mv %{buildroot}%{_bindir}/%{pypi_name}{,-%{python3_version}}
|
mv %{buildroot}%{_bindir}/%{pypi_name}{,-%{python3_version}}
|
||||||
%if %{with main_python}
|
%if %{with main_python}
|
||||||
ln -s %{pypi_name}-%{python3_version} %{buildroot}%{_bindir}/%{pypi_name}-3
|
ln -s %{pypi_name}-%{python3_version} %{buildroot}%{_bindir}/%{pypi_name}-3
|
||||||
ln -s %{pypi_name}-3 %{buildroot}%{_bindir}/%{pypi_name}
|
ln -s %{pypi_name}-3 %{buildroot}%{_bindir}/%{pypi_name}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%if %{without bootstrap}
|
|
||||||
# We can only use bdist_wheel when wheel is installed, hence we don't build the wheel in %%build
|
|
||||||
export PYTHONPATH=%{buildroot}%{python3_sitelib}
|
|
||||||
%py3_build_wheel
|
|
||||||
mkdir -p %{buildroot}%{python_wheel_dir}
|
mkdir -p %{buildroot}%{python_wheel_dir}
|
||||||
install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
|
install -p %{_pyproject_wheeldir}/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
|
||||||
%endif
|
|
||||||
|
|
||||||
|
|
||||||
|
%check
|
||||||
|
# Smoke test
|
||||||
|
%{py3_test_envvars} wheel-%{python3_version} version
|
||||||
|
%py3_check_import wheel
|
||||||
|
|
||||||
%if %{with tests}
|
%if %{with tests}
|
||||||
%check
|
|
||||||
rm setup.cfg # to drop pytest coverage options configured there
|
|
||||||
%pytest -v --ignore build
|
%pytest -v --ignore build
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
@ -120,13 +146,11 @@ rm setup.cfg # to drop pytest coverage options configured there
|
|||||||
%endif
|
%endif
|
||||||
%{python3_sitelib}/%{pypi_name}*/
|
%{python3_sitelib}/%{pypi_name}*/
|
||||||
|
|
||||||
%if %{without bootstrap}
|
|
||||||
%files -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
%files -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel
|
||||||
%license LICENSE.txt
|
%license LICENSE.txt
|
||||||
# we own the dir for simplicity
|
# we own the dir for simplicity
|
||||||
%dir %{python_wheel_dir}/
|
%dir %{python_wheel_dir}/
|
||||||
%{python_wheel_dir}/%{python_wheel_name}
|
%{python_wheel_dir}/%{python_wheel_name}
|
||||||
%endif
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
* Tue Mar 14 2023 Maxwell G <maxwell@gtmx.me> - 1:0.40.0-1
|
* Tue Mar 14 2023 Maxwell G <maxwell@gtmx.me> - 1:0.40.0-1
|
||||||
|
|||||||
7
wheel-entrypoint
Executable file
7
wheel-entrypoint
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
from wheel.cli import main
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
|
||||||
|
sys.exit(main())
|
||||||
Loading…
Reference in New Issue
Block a user