Blame SPECS/python3.11-pip.spec

be43fe
%global __python3 /usr/bin/python3.11
be43fe
%global python3_pkgversion 3.11
be43fe
be43fe
%bcond_with tests
be43fe
be43fe
%global srcname pip
be43fe
%global base_version 22.3.1
be43fe
%global upstream_version %{base_version}%{?prerel}
be43fe
%global python_wheel_name %{srcname}-%{upstream_version}-py3-none-any.whl
be43fe
be43fe
%global bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null)
be43fe
be43fe
Name:           python%{python3_pkgversion}-%{srcname}
be43fe
Version:        %{base_version}%{?prerel:~%{prerel}}
be43fe
Release:        2%{?dist}
be43fe
Summary:        A tool for installing and managing Python packages
be43fe
be43fe
# We bundle a lot of libraries with pip, which itself is under MIT license.
be43fe
# Here is the list of the libraries with corresponding licenses:
be43fe
be43fe
# appdirs: MIT
be43fe
# certifi: MPLv2.0
be43fe
# chardet: LGPLv2
be43fe
# colorama: BSD
be43fe
# CacheControl: ASL 2.0
be43fe
# distlib: Python
be43fe
# distro: ASL 2.0
be43fe
# html5lib: MIT
be43fe
# idna: BSD
be43fe
# ipaddress: Python
be43fe
# msgpack: ASL 2.0
be43fe
# packaging: ASL 2.0 or BSD
be43fe
# pep517: MIT
be43fe
# progress: ISC
be43fe
# pygments: BSD
be43fe
# pyparsing: MIT
be43fe
# requests: ASL 2.0
be43fe
# resolvelib: ISC
be43fe
# rich: MIT
be43fe
# setuptools: MIT
be43fe
# six: MIT
be43fe
# tenacity: ASL 2.0
be43fe
# tomli: MIT
be43fe
# typing-extensions: Python
be43fe
# urllib3: MIT
be43fe
# webencodings: BSD
be43fe
be43fe
License:        MIT and Python and ASL 2.0 and BSD and ISC and LGPLv2 and MPLv2.0 and (ASL 2.0 or BSD)
be43fe
URL:            https://pip.pypa.io/
be43fe
Source0:        https://github.com/pypa/pip/archive/%{upstream_version}/%{srcname}-%{upstream_version}.tar.gz
be43fe
%if 0%{?rhel} == 8
be43fe
# To generate the man pages for RHEL8 on a system with Python >= 3.7
be43fe
# rhpkg prep
be43fe
# cd into the pip folder
be43fe
# sed -i '/myst_parser/d;/sphinx_copybutton/d;/sphinx_inline_tabs/d;/sphinxcontrib.towncrier/d' docs/html/conf.py
be43fe
# sphinx-build-3 -b man  docs/man  docs/build/man  -c docs/html
be43fe
# tar -czf pip-22.3.1-man.tar.gz  --exclude=".[^/]*" -v docs/build/man
be43fe
# mv pip-22.3.1-man.tar.gz ..
be43fe
Source1:        pip-%{base_version}-man.tar.gz
be43fe
%endif #rhel8
be43fe
BuildArch:      noarch
be43fe
be43fe
# Prevent removing of the system packages installed under /usr/lib
be43fe
# when pip install -U is executed.
be43fe
# https://bugzilla.redhat.com/show_bug.cgi?id=1550368#c24
be43fe
# Could be replaced with https://www.python.org/dev/peps/pep-0668/
be43fe
Patch0:         remove-existing-dist-only-if-path-conflicts.patch
be43fe
be43fe
# Use the system level root certificate instead of the one bundled in certifi
be43fe
# https://bugzilla.redhat.com/show_bug.cgi?id=1655253
be43fe
# The same patch is a part of the RPM-packaged python-certifi
be43fe
Patch1:         dummy-certifi.patch
be43fe
be43fe
# Don't warn the user about pip._internal.main() entrypoint
be43fe
# In Fedora, we use that in ensurepip and users cannot do anything about it,
be43fe
# this warning is juts moot. Also, the warning breaks CPython test suite.
be43fe
Patch2:         nowarn-pip._internal.main.patch
be43fe
be43fe
# Don't warn the user about packaging's LegacyVersion being deprecated.
be43fe
# (This also breaks Python's test suite when warnings are treated as errors.)
be43fe
# Upstream issue: https://github.com/pypa/packaging/issues/368
be43fe
Patch3:         no-version-warning.patch
be43fe
be43fe
# Downstream only patch
be43fe
# Users might have local installations of pip from using
be43fe
# `pip install --user --upgrade pip` on older/newer versions.
be43fe
# If they do that and they run `pip` or  `pip3`, the one from /usr/bin is used.
be43fe
# However that's the one from this RPM package and the import in there might
be43fe
# fail (it tries to import from ~/.local, but older or newer pip is there with
be43fe
# a bit different API).
be43fe
# We add this patch as a dirty workaround to make /usr/bin/pip* work with
be43fe
# both pip10+ (from this RPM) and older or newer (19.3+) pip (from whatever).
be43fe
# A proper fix is to put ~/.local/bin in front of /usr/bin in the PATH,
be43fe
# however others are against that and we cannot change it for existing
be43fe
# installs/user homes anyway.
be43fe
# https://bugzilla.redhat.com/show_bug.cgi?id=1569488
be43fe
# https://bugzilla.redhat.com/show_bug.cgi?id=1571650
be43fe
# https://bugzilla.redhat.com/show_bug.cgi?id=1767212
be43fe
# WARNING: /usr/bin/pip* are entrypoints, this cannot be applied in %%prep!
be43fe
# %%patch10 doesn't work outside of %%prep, so we add it as a source
be43fe
# Note that since pip 20, old main() import paths are preserved for backwards
be43fe
# compatibility: https://github.com/pypa/pip/issues/7498
be43fe
# Meaning we don't need to update any of the older pips to support 20+
be43fe
# We also don't need to update Pythons to use new import path in ensurepip
be43fe
Source10:        pip-allow-different-versions.patch
be43fe
be43fe
be43fe
# Virtual provides for the packages bundled by pip.
be43fe
# You can generate it with:
be43fe
# %%{_rpmconfigdir}/pythonbundles.py --namespace 'python%%{1}dist' src/pip/_vendor/vendor.txt
be43fe
%global bundled() %{expand:
be43fe
Provides: bundled(python%{1}dist(cachecontrol)) = 0.12.11
be43fe
Provides: bundled(python%{1}dist(certifi)) = 2022.9.24
be43fe
Provides: bundled(python%{1}dist(chardet)) = 5
be43fe
Provides: bundled(python%{1}dist(colorama)) = 0.4.5
be43fe
Provides: bundled(python%{1}dist(distlib)) = 0.3.6
be43fe
Provides: bundled(python%{1}dist(distro)) = 1.7
be43fe
Provides: bundled(python%{1}dist(idna)) = 3.4
be43fe
Provides: bundled(python%{1}dist(msgpack)) = 1.0.4
be43fe
Provides: bundled(python%{1}dist(packaging)) = 21.3
be43fe
Provides: bundled(python%{1}dist(pep517)) = 0.13
be43fe
Provides: bundled(python%{1}dist(platformdirs)) = 2.5.2
be43fe
Provides: bundled(python%{1}dist(pygments)) = 2.13
be43fe
Provides: bundled(python%{1}dist(pyparsing)) = 3.0.9
be43fe
Provides: bundled(python%{1}dist(requests)) = 2.28.1
be43fe
Provides: bundled(python%{1}dist(resolvelib)) = 0.8.1
be43fe
Provides: bundled(python%{1}dist(rich)) = 12.5.1
be43fe
Provides: bundled(python%{1}dist(setuptools)) = 44
be43fe
Provides: bundled(python%{1}dist(six)) = 1.16
be43fe
Provides: bundled(python%{1}dist(tenacity)) = 8.1
be43fe
Provides: bundled(python%{1}dist(tomli)) = 2.0.1
be43fe
Provides: bundled(python%{1}dist(typing-extensions)) = 4.4
be43fe
Provides: bundled(python%{1}dist(urllib3)) = 1.26.12
be43fe
Provides: bundled(python%{1}dist(webencodings)) = 0.5.1
be43fe
}
be43fe
be43fe
# Some manylinux1 wheels need libcrypt.so.1.
be43fe
# Manylinux1, a common (as of 2019) platform tag for binary wheels, relies
be43fe
# on a glibc version that included ancient crypto functions, which were
be43fe
# moved to libxcrypt and then removed in:
be43fe
#  https://fedoraproject.org/wiki/Changes/FullyRemoveDeprecatedAndUnsafeFunctionsFromLibcrypt
be43fe
# The manylinux1 standard assumed glibc would keep ABI compatibility,
be43fe
# but that's only the case if libcrypt.so.1 (libxcrypt-compat) is around.
be43fe
# This should be solved in the next manylinux standard (but it may be
be43fe
# a long time until manylinux1 is phased out).
be43fe
# See: https://github.com/pypa/manylinux/issues/305
be43fe
# Note that manylinux is only applicable to x86 (both 32 and 64 bits)
be43fe
%global crypt_compat_recommends() %{expand:
be43fe
Recommends: (libcrypt.so.1()(64bit) if python%{1}(x86-64))
be43fe
Recommends: (libcrypt.so.1 if python%{1}(x86-32))
be43fe
}
be43fe
be43fe
BuildRequires:  python%{python3_pkgversion}-devel
be43fe
BuildRequires:  python%{python3_pkgversion}-rpm-macros
be43fe
# python3 bootstrap: this is rebuilt before the final build of python3, which
be43fe
# adds the dependency on python3-rpm-generators, so we require it manually
be43fe
# Note that the package prefix is always python3-, even if we build for 3.X
be43fe
BuildRequires:  python3-rpm-generators
be43fe
%if 0%{?rhel} == 9
be43fe
# We utilize the main Python's stack sphinx to build the manual pages
be43fe
BuildRequires:  python3-sphinx
be43fe
%endif #rhel9
be43fe
BuildRequires:  python%{python3_pkgversion}-setuptools
be43fe
BuildRequires:  bash-completion
be43fe
BuildRequires:  python%{python3_pkgversion}-wheel
be43fe
BuildRequires:  ca-certificates
be43fe
Requires:       ca-certificates
be43fe
be43fe
%if %{with tests}
be43fe
BuildRequires:  /usr/bin/git
be43fe
BuildRequires:  /usr/bin/hg
be43fe
BuildRequires:  /usr/bin/bzr
be43fe
BuildRequires:  /usr/bin/svn
be43fe
BuildRequires:  python%{python3_pkgversion}-setuptools-wheel
be43fe
BuildRequires:  python%{python3_pkgversion}-wheel-wheel
be43fe
BuildRequires:  python%{python3_pkgversion}-cryptography
be43fe
BuildRequires:  python%{python3_pkgversion}-mock
be43fe
BuildRequires:  python%{python3_pkgversion}-pytest
be43fe
BuildRequires:  python%{python3_pkgversion}-pretend
be43fe
BuildRequires:  python%{python3_pkgversion}-freezegun
be43fe
BuildRequires:  python%{python3_pkgversion}-scripttest
be43fe
BuildRequires:  python%{python3_pkgversion}-virtualenv
be43fe
BuildRequires:  python%{python3_pkgversion}-werkzeug
be43fe
BuildRequires:  python%{python3_pkgversion}-pyyaml
be43fe
BuildRequires:  python%{python3_pkgversion}-tomli-w
be43fe
BuildRequires:  python%{python3_pkgversion}-installer
be43fe
%endif
be43fe
be43fe
be43fe
# This was previously required and we keep it recommended because a lot of
be43fe
# sdists installed via pip will try to import setuptools.
be43fe
# But pip doesn't actually require setuptools.
be43fe
# It can install wheels without them and it can build wheels in isolation mode
be43fe
# (using setuptools/flit/poetry/... installed from PyPI).
be43fe
# Side note: pip bundles pkg_resources from setuptools for internal usage.
be43fe
Recommends:     python%{python3_pkgversion}-setuptools
be43fe
be43fe
# Require alternatives version that implements the --keep-foreign flag
be43fe
Requires(postun): alternatives >= 1.19.1-1
be43fe
be43fe
# python3.11 installs the alternatives master symlink to which we attach a slave
be43fe
Requires: python%{python3_pkgversion}
be43fe
Requires(post): python%{python3_pkgversion}
be43fe
Requires(postun): python%{python3_pkgversion}
be43fe
be43fe
# Virtual provides for the packages bundled by pip:
be43fe
%{bundled %{python3_pkgversion}}
be43fe
be43fe
%{crypt_compat_recommends %{python3_pkgversion}}
be43fe
be43fe
%description -n python%{python3_pkgversion}-%{srcname}
be43fe
pip is a package management system used to install and manage software packages
be43fe
written in Python. Many packages can be found in the Python Package Index
be43fe
(PyPI). pip is a recursive acronym that can stand for either "Pip Installs
be43fe
Packages" or "Pip Installs Python".
be43fe
be43fe
%package -n     %{python_wheel_pkg_prefix}-%{srcname}-wheel
be43fe
Summary:        The pip wheel
be43fe
Requires:       ca-certificates
be43fe
be43fe
# Virtual provides for the packages bundled by pip:
be43fe
%{bundled %{python3_pkgversion}}
be43fe
be43fe
%{crypt_compat_recommends %{python3_pkgversion}}
be43fe
be43fe
%description -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
be43fe
A Python wheel of pip to use with venv.
be43fe
be43fe
%prep
be43fe
%autosetup -p1 -n %{srcname}-%{upstream_version}
be43fe
be43fe
# this goes together with patch4
be43fe
rm src/pip/_vendor/certifi/*.pem
be43fe
be43fe
%if 0%{?rhel} == 9
be43fe
# Remove unneeded doc dependencies
be43fe
sed -i '/myst_parser/d;/sphinx_copybutton/d;/sphinx_inline_tabs/d;/sphinxcontrib.towncrier/d' docs/html/conf.py
be43fe
%endif #rhel9
be43fe
be43fe
# tests expect wheels in here
be43fe
ln -s %{python_wheel_dir} tests/data/common_wheels
be43fe
be43fe
# Remove windows executable binaries
be43fe
rm -v src/pip/_vendor/distlib/*.exe
be43fe
sed -i '/\.exe/d' setup.py
be43fe
be43fe
%build
be43fe
%py3_build_wheel
be43fe
be43fe
%if 0%{?rhel} == 9
be43fe
# Build the man pages
be43fe
export PYTHONPATH=./src/
be43fe
sphinx-build-3 -b man  docs/man  docs/build/man  -c docs/html
be43fe
%endif #rhel9
be43fe
be43fe
%install
be43fe
# The following is similar to %%pyproject_install, but we don't have
be43fe
# /usr/bin/pip yet, so we install using the wheel directly.
be43fe
# (This is not standard wheel usage, but the pip wheel supports it -- see
be43fe
#  pip/__main__.py)
be43fe
%{python3} dist/%{python_wheel_name}/pip install \
be43fe
    --root %{buildroot} \
be43fe
    --no-deps \
be43fe
    --disable-pip-version-check \
be43fe
    --progress-bar off \
be43fe
    --verbose \
be43fe
    --ignore-installed \
be43fe
    --no-warn-script-location \
be43fe
    --no-index \
be43fe
    --no-cache-dir \
be43fe
    --find-links dist \
be43fe
    'pip==%{upstream_version}'
be43fe
be43fe
# Install the man pages
be43fe
%if 0%{?rhel} == 8
be43fe
tar -xvf %{SOURCE1}
be43fe
%endif #rhel8
be43fe
pushd docs/build/man
be43fe
install -d %{buildroot}%{_mandir}/man1
be43fe
for MAN in *1; do
be43fe
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip%{python3_pkgversion}}
be43fe
install -pm0644 $MAN %{buildroot}%{_mandir}/man1/${MAN/pip/pip-%{python3_pkgversion}}
be43fe
done
be43fe
popd
be43fe
be43fe
# before we ln -s anything, we apply Source10 patch to all pips:
be43fe
for PIP in %{buildroot}%{_bindir}/pip*; do
be43fe
  patch -p1 --no-backup-if-mismatch $PIP < %{SOURCE10}
be43fe
done
be43fe
be43fe
mkdir -p %{buildroot}%{bashcompdir}
be43fe
PYTHONPATH=%{buildroot}%{python3_sitelib} \
be43fe
    %{buildroot}%{_bindir}/pip completion --bash \
be43fe
    > %{buildroot}%{bashcompdir}/pip%{python3_pkgversion}
be43fe
be43fe
# Make bash completion apply to all the 5 symlinks we install
be43fe
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip{,-}%{python3_pkgversion}/" \
be43fe
    -e s/_pip_completion/_pip%{python3_pkgversion}_completion/ \
be43fe
    %{buildroot}%{bashcompdir}/pip%{python3_pkgversion}
be43fe
be43fe
be43fe
# Provide symlinks to executables to comply with Fedora guidelines for Python
be43fe
ln -s ./pip%{python3_pkgversion} %{buildroot}%{_bindir}/pip-%{python3_pkgversion}
be43fe
be43fe
be43fe
# Make sure the INSTALLER is not pip and remove RECORD
be43fe
# %%pyproject macros do this for all packages
be43fe
echo rpm > %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/INSTALLER
be43fe
rm %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/RECORD
be43fe
be43fe
mkdir -p %{buildroot}%{python_wheel_dir}
be43fe
install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir}
be43fe
be43fe
# RHEL: Remove binaries conflicting with RHEL's main pip
be43fe
rm %{buildroot}%{_bindir}/pip
be43fe
rm %{buildroot}%{_bindir}/pip3
be43fe
be43fe
# All ghost files controlled by alternatives need to exist for the files
be43fe
# section check to succeed
be43fe
touch %{buildroot}%{_bindir}/pip3
be43fe
touch %{buildroot}%{_bindir}/pip-3
be43fe
be43fe
%check
be43fe
%if 0%{?rhel} == 9
be43fe
# Verify bundled provides are up to date
be43fe
%{_rpmconfigdir}/pythonbundles.py src/pip/_vendor/vendor.txt --namespace 'python%{python3_pkgversion}dist' \
be43fe
    --compare-with '%{bundled %{python3_pkgversion}}'
be43fe
%endif #rhel9
be43fe
be43fe
%if %{with tests}
be43fe
# Upstream tests
be43fe
# bash completion tests only work from installed package
be43fe
pytest_k='not completion'
be43fe
be43fe
# --deselect'ed tests are not compatible with the latest virtualenv
be43fe
# These files contain almost 500 tests so we should enable them back
be43fe
# as soon as pip will be compatible upstream
be43fe
# https://github.com/pypa/pip/pull/8441
be43fe
%pytest -m 'not network' -k "$(echo $pytest_k)" \
be43fe
    --deselect tests/functional --deselect tests/lib/test_lib.py
be43fe
%endif
be43fe
be43fe
%post -n python%{python3_pkgversion}-%{srcname}
be43fe
alternatives --add-slave python3 %{_bindir}/python%{python3_version} \
be43fe
    %{_bindir}/pip3 \
be43fe
    pip3 \
be43fe
    %{_bindir}/pip%{python3_version}
be43fe
alternatives --add-slave python3 %{_bindir}/python%{python3_version} \
be43fe
    %{_bindir}/pip-3 \
be43fe
    pip-3 \
be43fe
    %{_bindir}/pip-%{python3_version}
be43fe
be43fe
%postun -n python%{python3_pkgversion}-%{srcname}
be43fe
# Do this only during uninstall process (not during update)
be43fe
if [ $1 -eq 0 ]; then
be43fe
    # Only remove the slave links if the master link for python3 still exists.
be43fe
    # Due to a possible bug in yum, python3.11 gets removed before python3.11-pip
be43fe
    # even though we have declared Requires(postun): python3.11
be43fe
    EXISTS=`alternatives --display python3 | \
be43fe
          grep -c "^/usr/bin/python%{python3_version} - priority [0-9]*"`
be43fe
be43fe
    if [ $EXISTS -ne 0 ]; then
be43fe
        alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \
be43fe
            pip3
be43fe
        alternatives --keep-foreign --remove-slave python3 %{_bindir}/python%{python3_version} \
be43fe
            pip-3
be43fe
    fi
be43fe
fi
be43fe
be43fe
%files -n python%{python3_pkgversion}-%{srcname}
be43fe
%doc README.rst
be43fe
%license %{python3_sitelib}/pip-%{upstream_version}.dist-info/LICENSE.txt
be43fe
%{_mandir}/man1/pip%{python3_pkgversion}.*
be43fe
%{_mandir}/man1/pip%{python3_pkgversion}-*.*
be43fe
%{_mandir}/man1/pip-%{python3_pkgversion}.*
be43fe
%{_mandir}/man1/pip-%{python3_pkgversion}-*.*
be43fe
%{_bindir}/pip%{python3_pkgversion}
be43fe
%{_bindir}/pip-%{python3_pkgversion}
be43fe
%{python3_sitelib}/pip*
be43fe
%dir %{bashcompdir}
be43fe
%{bashcompdir}/pip%{python3_pkgversion}
be43fe
%ghost %{_bindir}/pip3
be43fe
%ghost %{_bindir}/pip-3
be43fe
be43fe
%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel
be43fe
%license LICENSE.txt
be43fe
# we own the dir for simplicity
be43fe
%dir %{python_wheel_dir}/
be43fe
%{python_wheel_dir}/%{python_wheel_name}
be43fe
be43fe
%changelog
be43fe
* Mon Jan 30 2023 Charalampos Stratakis <cstratak@redhat.com> - 22.3.1-2
be43fe
- Add BuildRequires on python3.11-rpm-macros
be43fe
be43fe
* Wed Aug 03 2022 Charalampos Stratakis <cstratak@redhat.com> - 22.3.1-1
be43fe
- Initial package
be43fe
- Fedora contributions by:
be43fe
      # Bill Nottingham <notting@fedoraproject.org>
be43fe
      # Charalampos Stratakis <cstratak@redhat.com>
be43fe
      # David Malcolm <dmalcolm@redhat.com>
be43fe
      # Dennis Gilmore <dennis@ausil.us>
be43fe
      # Jon Ciesla <limburgher@gmail.com>
be43fe
      # Karolina Surma <ksurma@redhat.com>
be43fe
      # Kevin Fenzi <kevin@fedoraproject.org>
be43fe
      # Kevin Kofler <Kevin@tigcc.ticalc.org>
be43fe
      # Luke Macken <lmacken@redhat.com>
be43fe
      # Lumir Balhar <lbalhar@redhat.com>
be43fe
      # Marcel Plch <mplch@redhat.com>
be43fe
      # Matej Stuchlik <mstuchli@redhat.com>
be43fe
      # Michal Cyprian <m.cyprian@gmail.com>
be43fe
      # Miro Hrončok <miro@hroncok.cz>
be43fe
      # Orion Poplawski <orion@cora.nwra.com>
be43fe
      # Pádraig Brady <P@draigBrady.com>
be43fe
      # Peter Halliday <hoangelos@fedoraproject.org>
be43fe
      # Petr Viktorin <pviktori@redhat.com>
be43fe
      # Robert Kuska <rkuska@redhat.com>
be43fe
      # Slavek Kabrda <bkabrda@redhat.com>
be43fe
      # Tim Flink <tflink@fedoraproject.org>
be43fe
      # Tomáš Hrnčiar <thrnciar@redhat.com>
be43fe
      # Tomas Orsava <torsava@redhat.com>
be43fe
      # Toshio Kuratomi <toshio@fedoraproject.org>
be43fe
      # Ville Skyttä <ville.skytta@iki.fi>