5b97b5b
%global srcname setuptools
Matej Stuchlik ce1bf68
2c17e79
# used when bootstrapping new Python versions
2c17e79
%bcond bootstrap 0
80ce5dc
bb8149d
# Similar to what we have in pythonX.Y.spec files.
bb8149d
# If enabled, provides unversioned executables and other stuff.
bb8149d
# Disable it if you build this package in an alternative stack.
2c17e79
%bcond main_python 1
2c17e79
2c17e79
# The original RHEL N+1 content set is defined by (build)dependencies
2c17e79
# of the packages in Fedora ELN. Hence we disable tests and documentation here
2c17e79
# to prevent pulling many unwanted packages in.
2c17e79
# We intentionally keep this enabled on EPEL.
2c17e79
%bcond tests %[%{without bootstrap} && (%{defined fedora} || %{defined epel})]
Robert Kuska 30ed86d
524eb44
%global python_wheel_name %{srcname}-%{version}-py3-none-any.whl
9eb4e2d
9eb4e2d
Name:           python-setuptools
818fa29
# When updating, update the bundled libraries versions bellow!
20fe514
Version:        69.2.0
13ffb76
Release:        %autorelease
613f26d
Summary:        Easily build and distribute Python packages
818fa29
# setuptools is MIT
8ae9b2a
# platformdirs is MIT
daf6a5c
# more-itertools is MIT
e02f56e
# ordered-set is MIT
8759867
# packaging is BSD-2-Clause OR Apache-2.0
8759867
# importlib-metadata is Apache-2.0
8759867
# importlib-resources is Apache-2.0
748e1cb
# jaraco.text is MIT
8759867
# typing-extensions is Python-2.0.1
748e1cb
# zipp is MIT
ebda604
# nspektr is MIT
ebda604
# tomli is MIT
6522fcf
# the setuptools logo is MIT
8759867
License:        MIT AND Apache-2.0 AND (BSD-2-Clause OR Apache-2.0) AND Python-2.0.1
33cc460
URL:            https://pypi.python.org/pypi/%{srcname}
61c2048
Source0:        %{pypi_source %{srcname} %{version}}
9eb4e2d
a957ae1
# Some test deps are optional and either not desired or not available in Fedora, thus this patch removes them.
641bd7b
Patch:          Remove-optional-or-unpackaged-test-deps.patch
63fb502
d01f5fa
# The `setup.py install` deprecation notice might be confusing for RPM packagers
d01f5fa
# adjust it, but only when $RPM_BUILD_ROOT is set
d01f5fa
Patch:          Adjust-the-setup.py-install-deprecation-message.patch
d01f5fa
9eb4e2d
BuildArch:      noarch
5b97b5b
8f62b16
BuildRequires:  python%{python3_pkgversion}-devel
d4b8cee
f404b22
%if %{with tests}
aab7290
BuildRequires:  gcc
d4b8cee
%endif
d4b8cee
76f349f
# python3 bootstrap: this is built before the final build of python3, which
76f349f
# adds the dependency on python3-rpm-generators, so we require it manually
d5c5982
# The minimal version is for bundled provides verification script to accept multiple files as input
d5c5982
BuildRequires:  python3-rpm-generators >= 12-8
cf94d87
cf94d87
%if %{without bootstrap}
cf94d87
BuildRequires:  pyproject-rpm-macros >= 0-44
cf94d87
# Not to use the pre-generated egg-info, we use setuptools from previous build to generate it
cf94d87
BuildRequires:  python%{python3_pkgversion}-setuptools
d4b8cee
%endif
9eb4e2d
6f21ed3
%description
613f26d
Setuptools is a collection of enhancements to the Python distutils that allow
6f21ed3
you to more easily build and distribute Python packages, especially ones that
6f21ed3
have dependencies on other packages.
6f21ed3
c8db69c
This package also contains the runtime components of setuptools, necessary to
bd7e1f7
execute the software that requires pkg_resources.
6f21ed3
818fa29
# Virtual provides for the packages bundled by setuptools.
d5c5982
# Bundled packages are defined in multiple files. Generate the list with:
d5c5982
# %%{_rpmconfigdir}/pythonbundles.py --namespace 'python%%{python3_pkgversion}dist' */_vendor/vendored.txt
bd7e1f7
%global bundled %{expand:
8ae9b2a
Provides: bundled(python%{python3_pkgversion}dist(importlib-metadata)) = 6
8ae9b2a
Provides: bundled(python%{python3_pkgversion}dist(importlib-resources)) = 5.10.2
748e1cb
Provides: bundled(python%{python3_pkgversion}dist(jaraco-text)) = 3.7
daf6a5c
Provides: bundled(python%{python3_pkgversion}dist(more-itertools)) = 8.8
e02f56e
Provides: bundled(python%{python3_pkgversion}dist(ordered-set)) = 3.1.1
7a6121a
Provides: bundled(python%{python3_pkgversion}dist(packaging)) = 23.1
f3ed497
Provides: bundled(python%{python3_pkgversion}dist(platformdirs)) = 2.6.2
f3ed497
Provides: bundled(python%{python3_pkgversion}dist(tomli)) = 2.0.1
748e1cb
Provides: bundled(python%{python3_pkgversion}dist(typing-extensions)) = 4.0.1
f3ed497
Provides: bundled(python%{python3_pkgversion}dist(typing-extensions)) = 4.4
748e1cb
Provides: bundled(python%{python3_pkgversion}dist(zipp)) = 3.7
818fa29
}
5b97b5b
8f62b16
%package -n python%{python3_pkgversion}-setuptools
41b54b7
Summary:        Easily build and distribute Python 3 packages
bd7e1f7
%{bundled}
41b54b7
3809284
# For users who might see ModuleNotFoundError: No module named 'pkg_resoureces'
b36e0d4
# NB: Those are two different provides: one contains underscore, the other hyphen
3809284
%py_provides    python%{python3_pkgversion}-pkg_resources
3809284
%py_provides    python%{python3_pkgversion}-pkg-resources
6401364
8f62b16
%description -n python%{python3_pkgversion}-setuptools
41b54b7
Setuptools is a collection of enhancements to the Python 3 distutils that allow
41b54b7
you to more easily build and distribute Python 3 packages, especially ones that
41b54b7
have dependencies on other packages.
41b54b7
c8db69c
This package also contains the runtime components of setuptools, necessary to
bd7e1f7
execute the software that requires pkg_resources.
957130b
d7f5288
%if %{without bootstrap}
524eb44
%package -n     %{python_wheel_pkg_prefix}-%{srcname}-wheel
d7f5288
Summary:        The setuptools wheel
bd7e1f7
%{bundled}
d7f5288
524eb44
%description -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
d7f5288
A Python wheel of setuptools to use with venv.
d7f5288
%endif
d7f5288
41b54b7
9eb4e2d
%prep
dbcd0a1
%autosetup -p1 -n %{srcname}-%{version}
3a0095a
%if %{without bootstrap}
3a0095a
# If we don't have setuptools installed yet, we use the pre-generated .egg-info
3a0095a
# See https://github.com/pypa/setuptools/pull/2543
3a0095a
# And https://github.com/pypa/setuptools/issues/2550
7a72517
# WARNING: We cannot remove this folder since Python 3.11.1,
7a72517
#          see https://github.com/pypa/setuptools/issues/3761
7a72517
#rm -r %%{srcname}.egg-info
3a0095a
%endif
476c777
Orion Poplawski 17a8507
# Strip shbang
9d511ca
find setuptools pkg_resources -name \*.py | xargs sed -i -e '1 {/^#!\//d}'
476c777
# Remove bundled exes
476c777
rm -f setuptools/*.exe
d4b8cee
# Don't ship these
cc43504
rm -r docs/conf.py
d4b8cee
d4b8cee
%if %{without bootstrap}
d4b8cee
%generate_buildrequires
d4b8cee
%pyproject_buildrequires -r %{?with_tests:-x testing}
d4b8cee
%endif
8eda9e1
9eb4e2d
%build
d4b8cee
%if %{with bootstrap}
09798fc
%py3_build
d4b8cee
%else
d4b8cee
%pyproject_wheel
Matej Stuchlik ce1bf68
%endif
5b97b5b
5cd637b
41b54b7
%install
d4b8cee
%if %{with bootstrap}
d195d55
# The setup.py install command tries to import distutils
d195d55
# but the distutils-precedence.pth file is not yet respected
d195d55
# and Python 3.12+ no longer has distutils in the standard library.
d195d55
ln -s setuptools/_distutils distutils
d195d55
PYTHONPATH=$PWD %py3_install
d195d55
unlink distutils
d4b8cee
%else
d4b8cee
%pyproject_install
d4b8cee
%pyproject_save_files setuptools pkg_resources _distutils_hack
Matej Stuchlik ce1bf68
%endif
6f21ed3
d4b8cee
# https://github.com/pypa/setuptools/issues/2709
d4b8cee
rm -rf %{buildroot}%{python3_sitelib}/pkg_resources/tests/
5b97b5b
%if %{without bootstrap}
d4b8cee
sed -i '/\/pkg_resources\/tests\b/d' %{pyproject_files}
Orion Poplawski 17a8507
d4b8cee
# Install the wheel for the python-setuptools-wheel package
524eb44
mkdir -p %{buildroot}%{python_wheel_dir}
524eb44
install -p %{_pyproject_wheeldir}/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
d7f5288
%endif
d7f5288
d4b8cee
41b54b7
%check
d5c5982
# Verify bundled provides are up to date
d5c5982
%{_rpmconfigdir}/pythonbundles.py */_vendor/vendored.txt --namespace 'python%{python3_pkgversion}dist' --compare-with '%{bundled}'
d5c5982
d4b8cee
# Regression test, the tests are not supposed to be installed
d4b8cee
test ! -d %{buildroot}%{python3_sitelib}/pkg_resources/tests
d4b8cee
test ! -d %{buildroot}%{python3_sitelib}/setuptools/tests
d4b8cee
368763e
%if %{without bootstrap}
cf94d87
# Regression test, the wheel should not be larger than 900 kB
cf94d87
# https://bugzilla.redhat.com/show_bug.cgi?id=1914481#c3
cf94d87
test $(stat --format %%s %{_pyproject_wheeldir}/%{python_wheel_name}) -lt 900000
cf94d87
368763e
%pyproject_check_import
368763e
%endif
368763e
368763e
%if %{with tests}
d4b8cee
# https://github.com/pypa/setuptools/discussions/2607
d4b8cee
rm pyproject.toml
7be6637
49b0dc3
# Upstream tests
d4b8cee
# --ignore=setuptools/tests/test_integration.py
748e1cb
# --ignore=setuptools/tests/integration/
ebda604
# --ignore=setuptools/tests/config/test_apply_pyprojecttoml.py
748e1cb
# -k "not test_pip_upgrade_from_source"
d4b8cee
#   the tests require internet connection
905fef4
# --ignore=setuptools/tests/test_editable_install.py
748e1cb
#   the tests require pip-run which we don't have in Fedora
748e1cb
PRE_BUILT_SETUPTOOLS_WHEEL=%{_pyproject_wheeldir}/%{python_wheel_name} \
748e1cb
PYTHONPATH=$(pwd) %pytest \
748e1cb
 --ignore=setuptools/tests/test_integration.py \
748e1cb
 --ignore=setuptools/tests/integration/ \
97feee3
 --ignore=setuptools/tests/test_editable_install.py \
ebda604
 --ignore=setuptools/tests/config/test_apply_pyprojecttoml.py \
7a6121a
 --ignore=tools/finalize.py \
7a6121a
 -k "not test_pip_upgrade_from_source and not test_setup_requires_honors_fetch_params"
f404b22
%endif # with tests
5cd637b
5b97b5b
d4b8cee
%files -n python%{python3_pkgversion}-setuptools %{?!with_bootstrap:-f %{pyproject_files}}
54eaa03
%license LICENSE
7a6121a
%doc docs/* NEWS.rst README.rst
d4b8cee
%{python3_sitelib}/distutils-precedence.pth
d4b8cee
%if %{with bootstrap}
d4b8cee
%{python3_sitelib}/setuptools-%{version}-py%{python3_version}.egg-info/
Orion Poplawski a6f3bb1
%{python3_sitelib}/pkg_resources/
d4b8cee
%{python3_sitelib}/setuptools/
55659ca
%{python3_sitelib}/_distutils_hack/
d4b8cee
%endif
9eb4e2d
d7f5288
%if %{without bootstrap}
524eb44
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
d7f5288
%license LICENSE
d7f5288
# we own the dir for simplicity
524eb44
%dir %{python_wheel_dir}/
524eb44
%{python_wheel_dir}/%{python_wheel_name}
d7f5288
%endif
d7f5288
5673c1a
9eb4e2d
%changelog
13ffb76
%autochangelog