File python-setuptools.spec of Package python-setuptools.38785
#
# spec file for package python-setuptools
#
# Copyright (c) 2025 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
%bcond_without test
%bcond_with wheel
# Test just don't work with Python 2
%define skip_python2 1
%else
%if "%{flavor}" == "wheel"
%define psuffix -wheel
%bcond_without wheel
%else
%define psuffix %{nil}
%bcond_with test
%bcond_with wheel
%endif
%endif
Name: python-setuptools%{psuffix}
Version: 40.6.2
Release: 0
URL: http://pypi.python.org/pypi/setuptools
Summary: Easily download, build, install, upgrade, and uninstall Python packages
License: Python-2.0 OR ZPL-2.0
Group: Development/Languages/Python
Source: https://pypi.python.org/packages/source/s/setuptools/setuptools-%{version}.zip
Source1: psfl.txt
Source2: zpl.txt
Patch1: setuptools-5.4.1-create-sitedir.patch
# NOTE(toabctl): Fix for SLE11SP3 test failures
Patch3: fix-sle11-test-failure.patch
# PATCH-FIX-UPSTREAM CVE-2022-40897-ReDos.patch bsc#1206667
Patch4: CVE-2022-40897-ReDos.patch
# PATCH-FIX-UPSTREAM CVE-2024-6345 bsc#1228105
Patch5: CVE-2024-6345-code-execution-via-download-funcs.patch
# PATCH-FIX-UPSTREAM CVE-2025-47273.patch bsc#1243313, gh#pypa/setuptools@250a6d17978f
Patch6: CVE-2025-47273.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: %{python_module packaging}
BuildRequires: %{python_module xml}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
BuildRequires: unzip
# for tests
BuildRequires: %{python_module mock}
BuildRequires: %{python_module pytest}
# needed for SLE
Requires: python
Requires: python-packaging
Requires: python-xml
Recommends: ca-certificates-mozilla
Requires(post): update-alternatives
Requires(postun): update-alternatives
# NOTE(saschpe): Distribute was merged into 0.7.x, so even though distribute
# obsoletes setuptools < 0.6.45, current setuptools obsoletes distribute again
Provides: python-distribute = %{version}
Obsoletes: python-distribute < %{version}
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
BuildArch: noarch
%endif
%if %{with wheel}
BuildRequires: %{python_module wheel}
%endif
%python_subpackages
%description
setuptools is a collection of enhancements to the Python distutils that
allow you to more easily build and distribute Python packages,
especially ones that have dependencies on other packages.
%prep
%setup -q -n setuptools-%{version}
%patch1 -p1
%if 0%{?suse_version} && 0%{?suse_version} <= 1220
%patch3 -p1
%endif
%patch4 -p1
%patch5 -p1
%patch6 -p1
find . -type f -name "*.orig" -delete
# strip shebangs to fix rpmlint warnings
# "explain the sed":
# 1 = first line only
# s@...@...@ = same as s/.../.../ except with @ instead of /
# ^ = start; #!/ = shebang leading characters; .* = rest of line; $ = end
# replace with nothing
sed -r -i '1s@^#!/.*$@@' setuptools/command/easy_install.py \
pkg_resources/_vendor/appdirs.py
%build
%if ! %{with wheel}
%python_build
%else
%python_exec setup.py bdist_wheel --universal
%endif
%install
%if !%{with test} && !%{with wheel}
%python_install
%prepare_alternative easy_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%endif
%if %{with wheel}
%python_expand install -D -m 0644 -t %{buildroot}%{$python_sitelib}/../wheels dist/*.whl
%endif
%check
%if %{with test}
# the 4 skipped test rely on the bundled packages but they are
# not available on virtualenv; this is expected behaviour
export LANG=en_US.UTF-8
# tests need imports local source dir
export PYTHONPATH=$(pwd)
%pytest --ignore setuptools/tests/test_virtualenv.py -k 'not (test_clean_env_install or test_pip_upgrade_from_source or test_test_command_install_requirements or test_no_missing_dependencies or test_build_wheel or test_wheel_install or test_prepare_metadata_for_build_wheel or test_namespace_package_importable or test_namespace_package_installed_and_cwd or test_packages_in_the_same_namespace_installed_and_cwd)'
%endif
%if !%{with test} && !%{with wheel}
%post
%python_install_alternative easy_install
%postun
%python_uninstall_alternative easy_install
%endif
%files %{python_files}
%defattr(-,root,root,-)
%if !%{with test} && !%{with wheel}
%doc CHANGES.rst README.rst
%python_alternative %{_bindir}/easy_install
%{python_sitelib}/setuptools
%{python_sitelib}/setuptools-%{version}-py%{python_version}.egg-info
%{python_sitelib}/easy_install.py*
%pycache_only %{python_sitelib}/__pycache__/easy_install.*
%dir %{python_sitelib}/pkg_resources
%{python_sitelib}/pkg_resources/*
%endif
%if %{with wheel}
%dir %{python_sitelib}/../wheels
%{python_sitelib}/../wheels/*
%endif
%changelog