python-pip/python-pip.spec
2020-08-25 11:47:20 +08:00

183 lines
5.6 KiB
RPMSpec

%bcond_without python2
%global srcname pip
%global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
%global python_wheeldir %{_datadir}/python-wheels
%global _description \
pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.
%global bashcompdir %(b=$(pkg-config --variable=completionsdir bash-completion 2>/dev/null); echo ${b:-%{_sysconfdir}/bash_completion.d})
Name: python-%{srcname}
Version: 20.2.2
Release: 1
Summary: A tool for installing and managing Python packages
License: MIT and Python and ASL 2.0 and BSD and ISC and LGPLv2 and MPLv2.0 and (ASL 2.0 or BSD)
URL: http://www.pip-installer.org
Source0: https://files.pythonhosted.org/packages/source/p/%{srcname}/%{srcname}-%{version}.tar.gz
BuildArch: noarch
Patch1: allow-stripping-given-prefix-from-wheel-RECORD-files.patch
Patch2: emit-a-warning-when-running-with-root-privileges.patch
Patch3: remove-existing-dist-only-if-path-conflicts.patch
Patch6000: dummy-certifi.patch
%description %{_description}
%package -n python2-%{srcname}
Summary: %{summary}
BuildRequires: python2-devel python2-setuptools ca-certificates
Requires: python2-setuptools ca-certificates
BuildRequires: python2-pip python2-wheel
%{?python_provide:%python_provide python2-%{srcname}}
%description -n python2-%{srcname} %{_description}
%package -n python%{python3_pkgversion}-%{srcname}
Summary: %{summary}
BuildRequires: python%{python3_pkgversion}-devel python%{python3_pkgversion}-setuptools bash-completion ca-certificates
Requires: python%{python3_pkgversion}-setuptools ca-certificates
BuildRequires: python%{python3_pkgversion}-pip python%{python3_pkgversion}-wheel
%{?python_provide:%python_provide python%{python3_pkgversion}-%{srcname}}
%description -n python%{python3_pkgversion}-%{srcname} %{_description}
%package_help
%package wheel
Summary: The pip wheel
Requires: ca-certificates
%description wheel
A Python wheel of pip to use with venv
%prep
%autosetup -n %{srcname}-%{version} -p1
%build
%py2_build
%py3_build_wheel
%install
%{__python3} dist/%{python_wheelname}/pip install \
--root %{buildroot} \
--no-deps \
--no-cache-dir \
--no-index \
--ignore-installed \
--find-links dist \
'pip==%{version}'
rm %{buildroot}%{_bindir}/pip
%{__python2} dist/%{python_wheelname}/pip install \
--root %{buildroot} \
--no-deps \
--no-cache-dir \
--no-index \
--ignore-installed \
--find-links dist \
'pip==%{version}'
%if %{with doc}
pushd docs/build/man
install -d %{buildroot}%{_mandir}/man1
for MAN in *1; do
install -pm0644 $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
done
popd
%endif
# before we ln -s anything, we apply Source10 patch to all pips:
#for PIP in %{buildroot}%{_bindir}/pip*; do
#% patch -p1 --no-backup-if-mismatch $PIP < %{SOURCE10}
#done
mkdir -p %{buildroot}%{bashcompdir}
PYTHONPATH=%{buildroot}%{python3_sitelib} \
%{buildroot}%{_bindir}/pip completion --bash \
> %{buildroot}%{bashcompdir}/pip3
# Make bash completion apply to all the 5 symlinks we install
sed -i -e "s/^\\(complete.*\\) pip\$/\\1 pip pip{,-}{3,%{python3_version}}/" \
-e s/_pip_completion/_pip3_completion/ \
%{buildroot}%{bashcompdir}/pip3
# Provide symlinks to executables to comply with Fedora guidelines for Python
ln -s ./pip%{python3_version} %{buildroot}%{_bindir}/pip-%{python3_version}
ln -s ./pip-%{python3_version} %{buildroot}%{_bindir}/pip-3
# Make sure the INSTALLER is not pip, otherwise Patch2 won't work
# %%pyproject macros do this for all packages
echo rpm > %{buildroot}%{python3_sitelib}/pip-20.2.2.dist-info/INSTALLER
mkdir -p %{buildroot}%{python_wheeldir}
install -p dist/%{python_wheelname} -t %{buildroot}%{python_wheeldir}
%files -n python2-%{srcname}
%license LICENSE.txt
%{_bindir}/pip
%{_bindir}/pip2
%{_bindir}/pip%{python2_version}
%{python2_sitelib}/pip*
%dir %{bashcompdir}
%dir %(dirname %{bashcompdir})
%files -n python%{python3_pkgversion}-%{srcname}
%license LICENSE.txt
%{_bindir}/pip3
%{_bindir}/pip-3*
%{_bindir}/pip%{python3_version}
%{python3_sitelib}/pip*
%dir %{bashcompdir}
%{bashcompdir}/pip3*
%dir %(dirname %{bashcompdir})
%files help
%doc README.rst
%files wheel
%license LICENSE.txt
%dir %{python_wheeldir}/
%{python_wheeldir}/%{python_wheelname}
%changelog
* Tue Aug 25 2020 wenzhanli<wenzhanli2@huawei.com> - 20.2.2-1
- update to 20.2.2 and add python2 require
* Tue Jul 28 2020 jinzhimin<jinzhimin2@huawei.com> - 20.1.1-1
- update to 20.1.1
* Thu Feb 20 2020 chengquan3<chengquan3@huawei.com> - 18.0-12
- Type:bugfix
- ID:NA
- SUG:NA
- DESC: Remove incorrect provision of python-wheel
* Sat Nov 16 2019 huzhiyu <huzhiyu1@huawei.com> - 18.0-11
- fix ca-certificate bad requires
* Fri Oct 15 2019 lvying<lvying6@huawei.com> - 18.0-10
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: split same wheel file from python2-pip and python3-pip
* Sun Sep 29 2019 yefei <yefei25@huawei.com> - 18.0-9
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Synchronize patches
* Sat Sep 28 2019 yefei <yefei25@huawei.com> - 18.0-8
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: add bash completion and repair python2 interpreter path
* Wed Sep 25 2019 openEuler Buildteam <buildteam@openeuler.org> - 18.0-7
- Type:enhancement
- ID:NA
- SUG:NA
- DESC: Synchronize a patch
* Mon Sep 23 2019 openEuler Buildteam <buildteam@openeuler.org> - 18.0-6
- Package init