#47 Make setuptools ready for alternative Python stacks
Merged 3 years ago by churchyard. Opened 3 years ago by lbalhar.
rpms/ lbalhar/python-setuptools compatibility  into  master

file modified
+26 -18
@@ -4,6 +4,10 @@ 

  #           because tests need pip.

  %bcond_with bootstrap

  %bcond_without tests

+ # Similar to what we have in pythonX.Y.spec files.

+ # If enabled, provides unversioned executables and other stuff.

+ # Disable it if you build this package in an alternative stack.

+ %bcond_without main_python

  

  %if %{without bootstrap}

  %global python_wheelname %{srcname}-%{version}-py3-none-any.whl
@@ -32,18 +36,18 @@ 

  

  BuildRequires:  gcc

  

- BuildRequires:  python3-devel

+ BuildRequires:  python%{python3_pkgversion}-devel

  %if %{with tests}

- BuildRequires:  python3-pip

- BuildRequires:  python3-pytest

- BuildRequires:  python3-mock

- BuildRequires:  python3-pytest-fixture-config

- BuildRequires:  python3-pytest-virtualenv

- BuildRequires:  python3-jaraco-envs

+ BuildRequires:  python%{python3_pkgversion}-pip

+ BuildRequires:  python%{python3_pkgversion}-pytest

+ BuildRequires:  python%{python3_pkgversion}-mock

+ BuildRequires:  python%{python3_pkgversion}-pytest-fixture-config

+ BuildRequires:  python%{python3_pkgversion}-pytest-virtualenv

+ BuildRequires:  python%{python3_pkgversion}-jaraco-envs

  %endif # with tests

  %if %{without bootstrap}

- BuildRequires:  python3-pip

- BuildRequires:  python3-wheel

+ BuildRequires:  python%{python3_pkgversion}-pip

+ BuildRequires:  python%{python3_pkgversion}-wheel

  # python3 bootstrap: this is built before the final build of python3, which

  # adds the dependency on python3-rpm-generators, so we require it manually

  # The minimal version is for bundled provides verification script
@@ -60,17 +64,16 @@ 

  

  # Virtual provides for the packages bundled by setuptools.

  # You can generate it with:

- # %%{_rpmconfigdir}/pythonbundles.py pkg_resources/_vendor/vendored.txt

+ # %%{_rpmconfigdir}/pythonbundles.py --namespace 'python%%{python3_pkgversion}dist' pkg_resources/_vendor/vendored.txt

  %global bundled %{expand:

- Provides: bundled(python3dist(appdirs)) = 1.4.3

- Provides: bundled(python3dist(packaging)) = 20.4

- Provides: bundled(python3dist(pyparsing)) = 2.2.1

- Provides: bundled(python3dist(six)) = 1.10

+ Provides: bundled(python%{python3_pkgversion}dist(appdirs)) = 1.4.3

+ Provides: bundled(python%{python3_pkgversion}dist(packaging)) = 20.4

+ Provides: bundled(python%{python3_pkgversion}dist(pyparsing)) = 2.2.1

+ Provides: bundled(python%{python3_pkgversion}dist(six)) = 1.10

  }

  

- %package -n python3-setuptools

+ %package -n python%{python3_pkgversion}-setuptools

  Summary:        Easily build and distribute Python 3 packages

- Conflicts:      python-setuptools < %{version}-%{release}

  %{bundled}

  

  %if %{with bootstrap}
@@ -79,7 +82,7 @@ 

  %endif

  

  

- %description -n python3-setuptools

+ %description -n python%{python3_pkgversion}-setuptools

  Setuptools is a collection of enhancements to the Python 3 distutils that allow

  you to more easily build and distribute Python 3 packages, especially ones that

  have dependencies on other packages.
@@ -148,6 +151,9 @@ 

  install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir}

  %endif

  

+ %if %{without main_python}

+ rm %{buildroot}%{_bindir}/easy_install

+ %endif

  

  %if %{with tests}

  %check
@@ -161,7 +167,7 @@ 

  %endif # with tests

  

  

- %files -n python3-setuptools

+ %files -n python%{python3_pkgversion}-setuptools

  %license LICENSE

  %doc docs/* CHANGES.rst README.rst

  %{python3_sitelib}/easy_install.py
@@ -170,7 +176,9 @@ 

  %{python3_sitelib}/_distutils_hack/

  %{python3_sitelib}/distutils-precedence.pth

  %{python3_sitelib}/__pycache__/*

+ %if %{with main_python}

  %{_bindir}/easy_install

+ %endif

  %{_bindir}/easy_install-3.*

  

  %if %{without bootstrap}

Two changes to make setuptools ready for alternative python stacks:

  • use %{python3_pkgversion} instead of hardcoded 3
  • use bcond main_python to disable unversioned parts which only the main package should ship

The only remaining problematic thing is the name of -wheel subpackage which should be also renamed to have a versioned prefix but because we'll rename the whole component, this will have to be fixed manually.

I can confirm that python3.8-setuptools[-wheel] are installable side-by-side with the main packages from rawhide. My plan is to prepare similar changes for pip and wheel and maybe other important packages.

Mere suggestion, what about:

%global python_wheeldir %{_datadir}/python%{!?with_main_python:%{python3_pkgversion}}-wheels

A stronger suggestion:

Don't do this, adapt this part of the specfile when imported as (for example) Python 3.11 (note that there are only 3 such packages and the spec file will need manual changes anyway).

2 new commits added

  • Use bcond main_python to disable unique unversioned parts
  • use `%{python3_pkgversion}` to make the specfile more universal
3 years ago

Please adapt the comment above the provides to actually generate this section as is (there is a --namespace option, so probably add --namespace 'python%%{python3_pkgversion}dist').

As a matter of fact, the conflict with python-setuptools can be removed entirely on Fedora 33+.

I am ok with the python3 -`> python%{python3_pkgversion} changes and the main_python bcond.

I am not so fond of the wheeldir change.

Build succeeded.

2 new commits added

  • Use bcond main_python to disable unique unversioned parts
  • use `%{python3_pkgversion}` to make the specfile more universal
3 years ago

rebased onto 530096e

3 years ago

All comments addressed.

Build succeeded.

One thing that I've missed before. The bcond should be defined as %bcond_without main_python.

rebased onto 8f62b16

3 years ago

Good catch, I'm testing the non-main version. Fixed.

Pull-Request has been merged by churchyard

3 years ago

Build succeeded.