Blame SPECS/python3.11-setuptools.spec

8f1fcd
%global __python3 /usr/bin/python3.11
8f1fcd
%global python3_pkgversion 3.11
8f1fcd
8f1fcd
%global srcname setuptools
8f1fcd
8f1fcd
# Some dependencies are missing on RHEL
8f1fcd
%bcond_with tests
8f1fcd
8f1fcd
#  WARNING  When bootstrapping, disable tests as well,
8f1fcd
#           because tests need pip.
8f1fcd
%bcond_with bootstrap
8f1fcd
# Similar to what we have in pythonX.Y.spec files.
8f1fcd
# If enabled, provides unversioned executables and other stuff.
8f1fcd
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
%global python_wheel_name %{srcname}-%{version}-py3-none-any.whl
8f1fcd
%global python3_record %{python3_sitelib}/%{srcname}-%{version}.dist-info/RECORD
8f1fcd
%endif
8f1fcd
8f1fcd
Name:           python%{python3_pkgversion}-setuptools
8f1fcd
# When updating, update the bundled libraries versions bellow!
8f1fcd
Version:        65.5.1
8f1fcd
Release:        2%{?dist}
8f1fcd
Summary:        Easily build and distribute Python packages
8f1fcd
# setuptools is MIT
8f1fcd
# appdirs is MIT
8f1fcd
# more-itertools is MIT
8f1fcd
# ordered-set is MIT
8f1fcd
# packaging is BSD or ASL 2.0
8f1fcd
# pyparsing is MIT
8f1fcd
# importlib-metadata is ASL 2.0
8f1fcd
# importlib-resources is ASL 2.0
8f1fcd
# jaraco.text is MIT
8f1fcd
# typing-extensions is Python
8f1fcd
# zipp is MIT
8f1fcd
# nspektr is MIT
8f1fcd
# tomli is MIT
8f1fcd
# the setuptools logo is MIT
8f1fcd
License:        MIT and ASL 2.0 and (BSD or ASL 2.0) and Python
8f1fcd
URL:            https://pypi.python.org/pypi/%{srcname}
8f1fcd
Source0:        %{pypi_source %{srcname} %{version}}
8f1fcd
8f1fcd
# Some test deps are optional and either not desired or not available in Fedora, thus this patch removes them.
8f1fcd
Patch0:          Remove-optional-or-unpackaged-test-deps.patch
8f1fcd
8f1fcd
BuildArch:      noarch
8f1fcd
8f1fcd
BuildRequires:  python%{python3_pkgversion}-devel
8f1fcd
BuildRequires:  python%{python3_pkgversion}-rpm-macros
8f1fcd
%if %{with tests}
8f1fcd
BuildRequires:  gcc
8f1fcd
BuildRequires:  python%{python3_pkgversion}-pip
8f1fcd
BuildRequires:  python%{python3_pkgversion}-pytest
8f1fcd
BuildRequires:  python%{python3_pkgversion}-pytest-xdist
8f1fcd
BuildRequires:  python%{python3_pkgversion}-pytest-virtualenv
8f1fcd
BuildRequires:  python%{python3_pkgversion}-jaraco-envs
8f1fcd
BuildRequires:  python%{python3_pkgversion}-jaraco-path
8f1fcd
BuildRequires:  python%{python3_pkgversion}-virtualenv
8f1fcd
BuildRequires:  python%{python3_pkgversion}-wheel
8f1fcd
BuildRequires:  python%{python3_pkgversion}-build
8f1fcd
BuildRequires:  python%{python3_pkgversion}-ini2toml
8f1fcd
BuildRequires:  python%{python3_pkgversion}-tomli-w
8f1fcd
%endif # with tests
8f1fcd
%if %{without bootstrap}
8f1fcd
# Not to use the pre-generated egg-info, we use setuptools from previous build to generate it
8f1fcd
BuildRequires:  python%{python3_pkgversion}-pip
8f1fcd
BuildRequires:  python%{python3_pkgversion}-wheel
8f1fcd
BuildRequires:  python%{python3_pkgversion}-setuptools
8f1fcd
# python3 bootstrap: this is built before the final build of python3, which
8f1fcd
# adds the dependency on python3-rpm-generators, so we require it manually
8f1fcd
BuildRequires:  python3-rpm-generators
8f1fcd
%endif # without bootstrap
8f1fcd
8f1fcd
# Virtual provides for the packages bundled by setuptools.
8f1fcd
# Bundled packages are defined in two files:
8f1fcd
# - pkg_resources/_vendor/vendored.txt, and
8f1fcd
# - setuptools/_vendor/vendored.txt
8f1fcd
# Merge them to one and then generate the list with:
8f1fcd
# %%{_rpmconfigdir}/pythonbundles.py --namespace 'python%%{python3_pkgversion}dist' allvendor.txt
8f1fcd
%global bundled %{expand:
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(appdirs)) = 1.4.3
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(importlib-metadata)) = 4.11.1
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(importlib-resources)) = 5.4
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(jaraco-text)) = 3.7
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(more-itertools)) = 8.8
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(ordered-set)) = 3.1.1
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(packaging)) = 21.3
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(pyparsing)) = 3.0.9
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(typing-extensions)) = 4.0.1
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(zipp)) = 3.7
8f1fcd
Provides: bundled(python%{python3_pkgversion}dist(tomli)) = 2.0.1
8f1fcd
}
8f1fcd
8f1fcd
%{bundled}
8f1fcd
8f1fcd
# For users who might see ModuleNotFoundError: No module named 'pkg_resources'
8f1fcd
# NB: Those are two different provides: one contains underscore, the other hyphen
8f1fcd
%py_provides    python%{python3_pkgversion}-pkg_resources
8f1fcd
%py_provides    python%{python3_pkgversion}-pkg-resources
8f1fcd
8f1fcd
%description
8f1fcd
Setuptools is a collection of enhancements to the Python 3 distutils that allow
8f1fcd
you to more easily build and distribute Python 3 packages, especially ones that
8f1fcd
have dependencies on other packages.
8f1fcd
8f1fcd
This package also contains the runtime components of setuptools, necessary to
8f1fcd
execute the software that requires pkg_resources.
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
%package -n     %{python_wheel_pkg_prefix}-%{srcname}-wheel
8f1fcd
Summary:        The setuptools wheel
8f1fcd
%{bundled}
8f1fcd
8f1fcd
%description -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
8f1fcd
A Python wheel of setuptools to use with venv.
8f1fcd
%endif
8f1fcd
8f1fcd
8f1fcd
%prep
8f1fcd
%autosetup -p1 -n %{srcname}-%{version}
8f1fcd
%if %{without bootstrap}
8f1fcd
# If we don't have setuptools installed yet, we use the pre-generated .egg-info
8f1fcd
# See https://github.com/pypa/setuptools/pull/2543
8f1fcd
# And https://github.com/pypa/setuptools/issues/2550
8f1fcd
# WARNING: We cannot remove this folder since Python 3.11.1,
8f1fcd
#          see https://github.com/pypa/setuptools/issues/3761
8f1fcd
#rm -r %%{srcname}.egg-info
8f1fcd
%endif
8f1fcd
8f1fcd
# Strip shbang
8f1fcd
find setuptools pkg_resources -name \*.py | xargs sed -i -e '1 {/^#!\//d}'
8f1fcd
# Remove bundled exes
8f1fcd
rm -f setuptools/*.exe
8f1fcd
# Don't ship these
8f1fcd
rm -r docs/conf.py
8f1fcd
8f1fcd
8f1fcd
%build
8f1fcd
%if %{without bootstrap}
8f1fcd
%py3_build_wheel
8f1fcd
%else
8f1fcd
%py3_build
8f1fcd
%endif
8f1fcd
8f1fcd
8f1fcd
%install
8f1fcd
%if %{without bootstrap}
8f1fcd
%py3_install_wheel %{python_wheel_name}
8f1fcd
%else
8f1fcd
%py3_install
8f1fcd
%endif
8f1fcd
8f1fcd
# https://github.com/pypa/setuptools/issues/2709
8f1fcd
rm -rf %{buildroot}%{python3_sitelib}/pkg_resources/tests/
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
sed -i '/^setuptools\/tests\//d' %{buildroot}%{python3_record}
8f1fcd
%endif
8f1fcd
8f1fcd
find %{buildroot}%{python3_sitelib} -name '*.exe' | xargs rm -f
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
mkdir -p %{buildroot}%{python_wheel_dir}
8f1fcd
install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
8f1fcd
%endif
8f1fcd
8f1fcd
%check
8f1fcd
8f1fcd
# Regression tests
8f1fcd
8f1fcd
#%%if 0%{?rhel} >= 9
8f1fcd
# The test cannot run on RHEL8 due to the test script missing from RPM.
8f1fcd
# Verify bundled provides are up to date
8f1fcd
# Disable the test for now as it requires python3-setuptools which is not included in the
8f1fcd
# minimal set of packages.
8f1fcd
#cat pkg_resources/_vendor/vendored.txt setuptools/_vendor/vendored.txt > allvendor.txt
8f1fcd
#%%{_rpmconfigdir}/pythonbundles.py allvendor.txt --namespace 'python%{python3_pkgversion}dist' --compare-with '%%{bundled}'
8f1fcd
#%%endif
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
# Regression test, the wheel should not be larger than 900 kB
8f1fcd
# https://bugzilla.redhat.com/show_bug.cgi?id=1914481#c3
8f1fcd
test $(stat --format %%s dist/%{python_wheel_name}) -lt 900000
8f1fcd
%endif
8f1fcd
8f1fcd
# Regression test, the tests are not supposed to be installed
8f1fcd
test ! -d %{buildroot}%{python3_sitelib}/pkg_resources/tests
8f1fcd
test ! -d %{buildroot}%{python3_sitelib}/setuptools/tests
8f1fcd
8f1fcd
# https://github.com/pypa/setuptools/discussions/2607
8f1fcd
rm pyproject.toml
8f1fcd
8f1fcd
# Upstream test suite
8f1fcd
8f1fcd
%if %{with tests}
8f1fcd
# Upstream tests
8f1fcd
# --ignore=setuptools/tests/test_integration.py
8f1fcd
# --ignore=setuptools/tests/integration/
8f1fcd
# --ignore=setuptools/tests/config/test_apply_pyprojecttoml.py
8f1fcd
# -k "not test_pip_upgrade_from_source"
8f1fcd
#   the tests require internet connection
8f1fcd
# --ignore=setuptools/tests/test_editable_install.py
8f1fcd
#   the tests require pip-run which we don't have in Fedora
8f1fcd
PRE_BUILT_SETUPTOOLS_WHEEL=dist/%{python_wheel_name} \
8f1fcd
PYTHONPATH=$(pwd) %pytest \
8f1fcd
 --ignore=setuptools/tests/test_integration.py \
8f1fcd
 --ignore=setuptools/tests/integration/ \
8f1fcd
 --ignore=setuptools/tests/test_editable_install.py \
8f1fcd
 --ignore=setuptools/tests/config/test_apply_pyprojecttoml.py \
8f1fcd
 -k "not test_pip_upgrade_from_source"
8f1fcd
%endif # with tests
8f1fcd
8f1fcd
8f1fcd
%files -n python%{python3_pkgversion}-setuptools
8f1fcd
%license LICENSE
8f1fcd
%doc docs/* CHANGES.rst README.rst
8f1fcd
%{python3_sitelib}/distutils-precedence.pth
8f1fcd
%{python3_sitelib}/pkg_resources/
8f1fcd
%{python3_sitelib}/setuptools*/
8f1fcd
%{python3_sitelib}/_distutils_hack/
8f1fcd
8f1fcd
%if %{without bootstrap}
8f1fcd
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
8f1fcd
%license LICENSE
8f1fcd
# we own the dir for simplicity
8f1fcd
%dir %{python_wheel_dir}/
8f1fcd
%{python_wheel_dir}/%{python_wheel_name}
8f1fcd
%endif
8f1fcd
8f1fcd
8f1fcd
%changelog
8f1fcd
* Mon Jan 30 2023 Charalampos Stratakis <cstratak@redhat.com> - 65.5.1-2
8f1fcd
- Disable bootstrap
8f1fcd
8f1fcd
* Wed Oct 12 2022 Charalampos Stratakis <cstratak@redhat.com> - 65.5.1-1
8f1fcd
- Initial package
8f1fcd
- Fedora contributions by:
8f1fcd
      # Bill Nottingham <notting@fedoraproject.org>
8f1fcd
      # Charalampos Stratakis <cstratak@redhat.com>
8f1fcd
      # David Malcolm <dmalcolm@redhat.com>
8f1fcd
      # Dennis Gilmore <dennis@ausil.us>
8f1fcd
      # dmalcolm <dmalcolm@fedoraproject.org>
8f1fcd
      # Haikel Guemar <hguemar@fedoraproject.org>
8f1fcd
      # Ignacio Vazquez-Abrams <ivazquez@fedoraproject.org>
8f1fcd
      # Jesse Keating <jkeating@fedoraproject.org>
8f1fcd
      # Karolina Surma <ksurma@redhat.com>
8f1fcd
      # Kevin Fenzi <kevin@scrye.com>
8f1fcd
      # Konstantin Ryabitsev <icon@fedoraproject.org>
8f1fcd
      # Lumir Balhar <lbalhar@redhat.com>
8f1fcd
      # Matej Stuchlik <mstuchli@redhat.com>
8f1fcd
      # Michal Cyprian <mcyprian@redhat.com>
8f1fcd
      # Miro Hrončok <miro@hroncok.cz>
8f1fcd
      # Nils Philippsen <nils@redhat.com>
8f1fcd
      # Orion Poplawski <orion@cora.nwra.com>
8f1fcd
      # Petr Viktorin <pviktori@redhat.com>
8f1fcd
      # Pierre-Yves Chibon <pingou@pingoured.fr>
8f1fcd
      # Ralph Bean <rbean@redhat.com>
8f1fcd
      # Randy Barlow <randy@electronsweatshop.com>
8f1fcd
      # Robert Kuska <rkuska@redhat.com>
8f1fcd
      # Thomas Spura <thomas.spura@gmail.com>
8f1fcd
      # Tomáš Hrnčiar <thrnciar@redhat.com>
8f1fcd
      # Tomas Orsava <torsava@redhat.com>
8f1fcd
      # Tomas Radej <tradej@redhat.com>
8f1fcd
      # tomspur <tomspur@fedoraproject.org>
8f1fcd
      # Toshio Kuratomi <toshio@fedoraproject.org>
8f1fcd
      # Troy Dawson <tdawson@redhat.com>
8f1fcd
      # Ville Skyttä <scop@fedoraproject.org>