Blame SPECS/python3.11-setuptools.spec

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