File python39-setuptools.spec of Package python39-setuptools

#
# spec file for package python39-setuptools
#
# Copyright (c) 2021 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/
#

%define python39_sitelib %{_prefix}/lib/python3.9/site-packages
Name:           python39-setuptools
Version:        44.1.1
Release:        0
Summary:        Enhancements to distutils for building and distributing Python packages
License:        MIT
Group:          Development/Languages/Python
URL:            https://github.com/pypa/setuptools
Source:         https://files.pythonhosted.org/packages/source/s/setuptools/setuptools-%{version}.zip
Patch0:         sort-for-reproducibility.patch
Patch1:         importlib.patch
# PATCH-FIX-UPSTREAM CVE-2022-40897-ReDos.patch bsc#1206667
Patch2:         CVE-2022-40897-ReDos.patch
# PATCH-FIX-UPSTREAM CVE-2024-6345 bsc#1228105
Patch3:         CVE-2024-6345-code-execution-via-download-funcs.patch
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
BuildRequires:  python39-base
BuildRequires:  unzip
# The dependency download feature may require SSL, which is in python3-base and python(2)
Requires:       python39
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     ca-certificates-mozilla
Provides:       python-distribute = %{version}
Obsoletes:      python-distribute < %{version}
BuildArch:      noarch

%description
setuptools is a collection of enhancements to the Python distutils that
allow you to build and distribute Python packages,
especially ones that have dependencies on other packages.

%prep
%setup -q -n setuptools-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1

# 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

%build
python3.9 setup.py build --executable=%{_bindir}/python3.9

%install
python3.9 setup.py install -O1 --skip-build --force \
    --root %{buildroot} --prefix %{_prefix}

# update-alternatives
mkdir -p %{buildroot}%{_bindir}
mv %{buildroot}%{_bindir}/easy_install{,-%{python_version}}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives/
touch %{buildroot}%{_sysconfdir}/alternatives/easy_install
ln -sf %{_sysconfdir}/alternatives/easy_install \
    %{buildroot}%{_bindir}/easy_install

%fdupes %{buildroot}%{python39_sitelib}

%post
%{_sbindir}/update-alternatives --install %{_bindir}/easy_install \
    easy_install %{_bindir}/easy_install-%{python_version} 39

%postun
if [ ! -f %{_bindir}/easy_install ] ; then
    %{_sbindir}/update-alternatives --remove easy_install %{_bindir}/easy_install-%{python_version}
fi

%files
%defattr(-,root,root)
%license LICENSE
%doc CHANGES.rst README.rst
%{_bindir}/easy_install*
%{python39_sitelib}/easy_install*
%{python39_sitelib}/setuptools
%{python39_sitelib}/setuptools-%{version}-py*.egg-info
%{python39_sitelib}/__pycache__/*.pyc
%dir %{python39_sitelib}/pkg_resources
%{python39_sitelib}/pkg_resources/*
%ghost %_sysconfdir/alternatives/easy_install

%changelog
openSUSE Build Service is sponsored by