From bce960f4b5833a160f3765e0e25951c5fd89f5cc Mon Sep 17 00:00:00 2001 From: yuanhui Date: Tue, 11 Apr 2023 15:56:28 +0800 Subject: [PATCH] Optimize the spec file Signed-off-by: yuanhui --- ...existing-dist-only-if-path-conflicts.patch | 0 ...-certifi.patch => 0002-dummy-certifi.patch | 0 ...ch => 0003-nowarn-pip._internal.main.patch | 0 ...ing.patch => 0004-no-version-warning.patch | 0 ...=> 0005-pip-allow-different-versions.patch | 0 python-pip.spec | 209 ++++++------------ 6 files changed, 67 insertions(+), 142 deletions(-) rename remove-existing-dist-only-if-path-conflicts.patch => 0001-remove-existing-dist-only-if-path-conflicts.patch (100%) rename dummy-certifi.patch => 0002-dummy-certifi.patch (100%) rename nowarn-pip._internal.main.patch => 0003-nowarn-pip._internal.main.patch (100%) rename no-version-warning.patch => 0004-no-version-warning.patch (100%) rename pip-allow-different-versions.patch => 0005-pip-allow-different-versions.patch (100%) diff --git a/remove-existing-dist-only-if-path-conflicts.patch b/0001-remove-existing-dist-only-if-path-conflicts.patch similarity index 100% rename from remove-existing-dist-only-if-path-conflicts.patch rename to 0001-remove-existing-dist-only-if-path-conflicts.patch diff --git a/dummy-certifi.patch b/0002-dummy-certifi.patch similarity index 100% rename from dummy-certifi.patch rename to 0002-dummy-certifi.patch diff --git a/nowarn-pip._internal.main.patch b/0003-nowarn-pip._internal.main.patch similarity index 100% rename from nowarn-pip._internal.main.patch rename to 0003-nowarn-pip._internal.main.patch diff --git a/no-version-warning.patch b/0004-no-version-warning.patch similarity index 100% rename from no-version-warning.patch rename to 0004-no-version-warning.patch diff --git a/pip-allow-different-versions.patch b/0005-pip-allow-different-versions.patch similarity index 100% rename from pip-allow-different-versions.patch rename to 0005-pip-allow-different-versions.patch diff --git a/python-pip.spec b/python-pip.spec index 69610b5..0b7c578 100644 --- a/python-pip.spec +++ b/python-pip.spec @@ -1,80 +1,32 @@ %define anolis_release 2 -%bcond_without python3 + %bcond_with tests %bcond_with doc -%global srcname pip -%global base_version 23.0.1 -%global upstream_version %{base_version}%{?prerel} -%global python_wheel_name %{srcname}-%{upstream_version}-py3-none-any.whl - +%global pypi_name pip %global bashcompdir %(pkg-config --variable=completionsdir bash-completion 2>/dev/null) Name: python-pip -Version: %{upstream_version} +Version: 23.0.1 Release: %{anolis_release}%{?dist} Summary: A tool for installing and managing Python package - License: MIT AND Python-2.0.1 AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND LGPL-2.1-only AND MPL-2.0 AND (Apache-2.0 OR BSD-2-Clause) URL: https://pip.pypa.io/ -Source0: https://github.com/pypa/pip/archive/%{upstream_version}/%{srcname}-%{upstream_version}.tar.gz +Source0: https://github.com/pypa/pip/archive/%{version}/%{pypi_name}-%{version}.tar.gz Source1: pip.aliyun.conf +Source10: 0005-pip-allow-different-versions.patch BuildArch: noarch -BuildRequires: python3-devel +BuildRequires: pkgconfig(python3) %if %{with tests} -BuildRequires: /usr/bin/git -BuildRequires: /usr/bin/hg -BuildRequires: /usr/bin/bzr -BuildRequires: /usr/bin/svn -BuildRequires: python-setuptools-wheel -BuildRequires: python-wheel-wheel +BuildRequires: git-core mercurial subversion breezy +BuildRequires: python-setuptools-wheel python-wheel-wheel %endif -# Prevent removing of the system packages installed under /usr/lib -# when pip install -U is executed. -# Could be replaced with https://www.python.org/dev/peps/pep-0668/ -Patch1: remove-existing-dist-only-if-path-conflicts.patch - -# Use the system level root certificate instead of the one bundled in certifi -# The same patch is a part of the RPM-packaged python-certifi -Patch2: dummy-certifi.patch - -# Don't warn the user about pip._internal.main() entrypoint -# In Fedora, we use that in ensurepip and users cannot do anything about it, -# this warning is juts moot. Also, the warning breaks CPython test suite. -Patch3: nowarn-pip._internal.main.patch - -# Don't warn the user about packaging's LegacyVersion being deprecated. -# (This also breaks Python's test suite when warnings are treated as errors.) -# Upstream issue: https://github.com/pypa/packaging/issues/368 -Patch4: no-version-warning.patch - -# Downstream only patch -# Users might have local installations of pip from using -# `pip install --user --upgrade pip` on older/newer versions. -# If they do that and they run `pip` or `pip3`, the one from /usr/bin is used. -# However that's the one from this RPM package and the import in there might -# fail (it tries to import from ~/.local, but older or newer pip is there with -# a bit different API). -# We add this patch as a dirty workaround to make /usr/bin/pip* work with -# both pip10+ (from this RPM) and older or newer (19.3+) pip (from whatever). -# A proper fix is to put ~/.local/bin in front of /usr/bin in the PATH, -# however others are against that and we cannot change it for existing -# installs/user homes anyway. -# WARNING: /usr/bin/pip* are entrypoints, this cannot be applied in %%prep! -# %%patch10 doesn't work outside of %%prep, so we add it as a source -# Note that since pip 20, old main() import paths are preserved for backwards -# compatibility: https://github.com/pypa/pip/issues/7498 -# Meaning we don't need to update any of the older pips to support 20+ -# We also don't need to update Pythons to use new import path in ensurepip -Source10: pip-allow-different-versions.patch - -%description -pip is a package management system used to install and manage software packages -written in Python. Many packages can be found in the Python Package Index -(PyPI). pip is a recursive acronym that can stand for either "Pip Installs -Packages" or "Pip Installs Python". +Patch0001: 0001-remove-existing-dist-only-if-path-conflicts.patch +Patch0002: 0002-dummy-certifi.patch +Patch0003: 0003-nowarn-pip._internal.main.patch +Patch0004: 0004-no-version-warning.patch %global bundled() %{expand: Provides: bundled(python%{1}dist(cachecontrol)) = 0.12.11 @@ -106,65 +58,39 @@ Provides: bundled(python%{1}dist(webencodings)) = 0.5.1 Recommends: (libcrypt.so.1()(64bit) if python%{1}(x86-64)) } -%package -n python%{python3_pkgversion}-%{srcname} +%description +pip is a package management system used to install and manage software packages +written in Python. Many packages can be found in the Python Package Index +(PyPI). pip is a recursive acronym that can stand for either "Pip Installs +Packages" or "Pip Installs Python". + +%package -n python3-%{pypi_name} Summary: A tool for installing and managing Python3 packages -BuildRequires: python%{python3_pkgversion}-devel -BuildRequires: python3-rpm-generators >= 11-8 -BuildRequires: python%{python3_pkgversion}-setuptools -BuildRequires: pkgconfig(bash-completion) +BuildRequires: python3-devel python3-rpm-generators >= 11-8 ca-certificates +BuildRequires: python3-wheel python3-setuptools pkgconfig(bash-completion) %if %{with tests} -BuildRequires: python%{python3_pkgversion}-cryptography -BuildRequires: python%{python3_pkgversion}-mock -BuildRequires: python%{python3_pkgversion}-pytest -BuildRequires: python%{python3_pkgversion}-pretend -BuildRequires: python%{python3_pkgversion}-freezegun -BuildRequires: python%{python3_pkgversion}-scripttest -BuildRequires: python%{python3_pkgversion}-virtualenv -BuildRequires: python%{python3_pkgversion}-werkzeug -BuildRequires: python%{python3_pkgversion}-pyyaml -BuildRequires: python%{python3_pkgversion}-tomli-w -BuildRequires: python%{python3_pkgversion}-installer +BuildRequires: python3-freezegun python3-scripttest +BuildRequires: python3-cryptography python3-mock python3-pretend +BuildRequires: python3-werkzeug python3-virtualenv python3-pytest +BuildRequires: python3-tomli-w python3-pyyaml python3-installer %endif -BuildRequires: python%{python3_pkgversion}-wheel -BuildRequires: ca-certificates -Requires: ca-certificates - -# This was previously required and we keep it recommended because a lot of -# sdists installed via pip will try to import setuptools. -# But pip doesn't actually require setuptools. -# It can install wheels without them and it can build wheels in isolation mode -# (using setuptools/flit/poetry/... installed from PyPI). -# Side note: pip bundles pkg_resources from setuptools for internal usage. -Recommends: python%{python3_pkgversion}-setuptools %{bundled 3} -Provides: pip = %{version}-%{release} +Requires: ca-certificates +Recommends: python3-setuptools +Provides: pip = %{version}-%{release} Provides: platform-python-pip = %{version}-%{release} -%description -n python%{python3_pkgversion}-%{srcname} +%description -n python3-%{pypi_name} pip is a package management system used to install and manage software packages written in Python. Many packages can be found in the Python Package Index (PyPI). pip is a recursive acronym that can stand for either "Pip Installs Packages" or "Pip Installs Python". -%if %{with doc} -%package doc -Summary: A documentation for a tool for installing and managing Python packages - -BuildRequires: python%{python3_pkgversion}-sphinx -BuildRequires: python%{python3_pkgversion}-sphinx-inline-tabs -BuildRequires: python%{python3_pkgversion}-sphinx-copybutton -BuildRequires: python%{python3_pkgversion}-myst-parser - -%description doc -A documentation for a tool for installing and managing Python packages - -%endif - -%package -n %{python_wheel_pkg_prefix}-%{srcname}-wheel +%package -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel Summary: The pip wheel Requires: ca-certificates @@ -172,27 +98,28 @@ Requires: ca-certificates %{crypt_compat_recommends 3} -%description -n %{python_wheel_pkg_prefix}-%{srcname}-wheel +%description -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel A Python wheel of pip to use with venv. +%if %{with doc} +%package -n python3-%{pypi_name}-doc +Summary: A documentation for a tool for installing and managing Python packages + +BuildRequires: python3-sphinx python3-sphinx-inline-tabs python3-sphinx-copybutton +BuildRequires: python3-myst-parser +Requires: python3-%{pypi_name} = %{EVR} + +%description -n python3-%{pypi_name}-doc +A documentation for a tool for installing and managing Python packages +%endif %prep -%autosetup -p1 -n %{srcname}-%{upstream_version} +%autosetup -n %{pypi_name}-%{version} -p1 -# this goes together with patch4 rm src/pip/_vendor/certifi/*.pem - -# Do not use furo as HTML theme in docs -# furo is not available in Fedora sed -i '/html_theme = "furo"/d' docs/html/conf.py - -# towncrier extension for Sphinx is not yet available in Fedora sed -i '/"sphinxcontrib.towncrier",/d' docs/html/conf.py - -# tests expect wheels in here ln -s %{python_wheel_dir} tests/data/common_wheels - -# Remove windows executable binaries rm -v src/pip/_vendor/distlib/*.exe sed -i '/\.exe/d' setup.py @@ -201,14 +128,13 @@ sed -i '/\.exe/d' setup.py %if %{with doc} export PYTHONPATH=./src/ -# from tox.ini sphinx-build-3 -b html docs/html docs/build/html -sphinx-build-3 -b man docs/man docs/build/man -c docs/html +sphinx-build-3 -b man docs/man docs/build/man -c docs/html rm -rf docs/build/html/{.doctrees,.buildinfo} %endif %install -%{python3} dist/%{python_wheel_name}/pip install \ +%{python3} dist/%{pypi_name}-%{version}-py3-none-any.whl/pip install \ --root %{buildroot} \ --no-deps \ --disable-pip-version-check \ @@ -219,13 +145,13 @@ rm -rf docs/build/html/{.doctrees,.buildinfo} --no-index \ --no-cache-dir \ --find-links dist \ - 'pip==%{upstream_version}' + 'pip==%{version}' %if %{with doc} pushd docs/build/man -install -d %{buildroot}%{_mandir}/man1 +mkdir -p %{buildroot}%{_mandir}/man1 for MAN in *1; do -install -pm0644 $MAN %{buildroot}%{_mandir}/man1/$MAN +install -m 0644 -p $MAN %{buildroot}%{_mandir}/man1/$MAN for pip in "pip3" "pip-3" "pip%{python3_version}" "pip-%{python3_version}"; do echo ".so $MAN" > %{buildroot}%{_mandir}/man1/${MAN/pip/$pip} done @@ -252,11 +178,11 @@ ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version} ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3 -echo rpm > %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/INSTALLER -rm %{buildroot}%{python3_sitelib}/pip-%{upstream_version}.dist-info/RECORD +echo rpm > %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/INSTALLER +rm %{buildroot}%{python3_sitelib}/pip-%{version}.dist-info/RECORD mkdir -p %{buildroot}%{python_wheel_dir} -install -p dist/%{python_wheel_name} -t %{buildroot}%{python_wheel_dir} +install -p dist/%{pypi_name}-%{version}-py3-none-any.whl -t %{buildroot}%{python_wheel_dir} install -D -m0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/pip.conf @@ -270,15 +196,8 @@ pytest_k='not completion' --deselect tests/functional --deselect tests/lib/test_lib.py --deselect tests/unit/test_build_env.py %endif -%files -n python%{python3_pkgversion}-%{srcname} -%doc README.rst -%license %{python3_sitelib}/pip-%{upstream_version}.dist-info/LICENSE.txt -%if %{with doc} -%{_mandir}/man1/pip.* -%{_mandir}/man1/pip-*.* -%{_mandir}/man1/pip3.* -%{_mandir}/man1/pip3-*.* -%endif +%files -n python3-%{pypi_name} +%license LICENSE.txt %config(noreplace) %{_sysconfdir}/pip.conf %{_bindir}/pip %{_bindir}/pip3 @@ -288,21 +207,27 @@ pytest_k='not completion' %{python3_sitelib}/pip* %dir %{bashcompdir} %{bashcompdir}/pip3 - %if %{with doc} -%files doc -%license LICENSE.txt -%doc README.rst -%doc docs/build/html +%{_mandir}/man1/pip.* +%{_mandir}/man1/pip-*.* +%{_mandir}/man1/pip3.* +%{_mandir}/man1/pip3-*.* %endif -%files -n %{python_wheel_pkg_prefix}-%{srcname}-wheel +%files -n %{python_wheel_pkg_prefix}-%{pypi_name}-wheel %license LICENSE.txt -# we own the dir for simplicity %dir %{python_wheel_dir}/ -%{python_wheel_dir}/%{python_wheel_name} +%{python_wheel_dir}/%{pypi_name}-%{version}-py3-none-any.whl + +%if %{with doc} +%files -n python3-%{pypi_name}-doc +%doc README.rst docs/build/html +%endif %changelog +* Tue Apr 11 2023 yuanhui - 23.0.1-3 +- Optimize the spec file + * Tue Mar 28 2023 mgb01105731 - 23.0.1-2 - Del Specific Fields -- Gitee