%bcond_with bootstrap
%bcond_without python3

%global srcname pip

%global python_wheelname %{srcname}-%{version}-py3-none-any.whl
%if %{without bootstrap}
%if %{with python3}
%global python3_wheelname %python_wheelname
%endif
%endif

Summary:        Pip installs Python packages.  An easy_install replacement
Summary(ja):    Pip は easy_install を置き換える Python パッケージインストーラです。
Name:           python-%{srcname}
Version:        21.3.1
Release:        1%{?_dist_release}
Group:          programming
Vendor:         Project Vine
Distribution:   Vine Linux

License:        MIT
URL:            https://pip.pypa.io/en/stable/
Source0:        https://pypi.python.org/packages/source/p/pip/%{srcname}-%{version}.tar.gz
# # Patch until the following issue gets implemented upstream:
# # https://github.com/pypa/pip/issues/1351
# Patch0:         allow-stripping-given-prefix-from-wheel-RECORD-files.patch

# # Downstream only patch
# # Emit a warning to the user if pip install is run with root privileges
# # Issue upstream: https://github.com/pypa/pip/issues/4288
# Patch1:         emit-a-warning-when-running-with-root-privileges.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root

BuildArch:      noarch
BuildRequires:  python-rpm-macros

%if %{with python3}
BuildRequires:  python3-rpm-macros
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
%if %{without bootstrap}
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
%endif
%endif

%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".


%if %{with python3}
%package -n     python3-%{srcname}
Summary:        A tool for installing and managing Python3 packages
Group:          programming
Requires:       python3-setuptools
Requires(post,postun): alternatives

%description -n python3-%{srcname}
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".
%endif


%prep
%setup -q -n %{srcname}-%{version}


%build
%if %{with python3}
%if %{without bootstrap}
%py3_build_wheel
%else
%py3_build
%endif
%endif # with python3


%install
%{__rm} -rf %{buildroot}

%if %{with python3}
%if %{without bootstrap}
%py3_install_wheel %{python3_wheelname}
%else
%py3_install
%endif
rm %{buildroot}%{_bindir}/pip
%endif # with python3


%clean
%{__rm} -rf %{buildroot}


%if %{with python3}
%pre -n python3-%{srcname}
if [ ! -L %{_bindir}/%{srcname} ]; then
  rm -f %{_bindir}/%{srcname}
fi

%post -n python3-%{srcname}
/sbin/update-alternatives \
  --install %{_bindir}/%{srcname} %{srcname} \
  %{_bindir}/%{srcname}%{python3_version} %{python3_version_nodots}

%preun -n python3-%{srcname}
if [ "$1" = 0 ]; then
  /sbin/update-alternatives \
    --remove %{srcname} %{_bindir}/%{srcname}%{python3_version}
fi
%endif


%if %{with python3}
%files -n python3-pip
%defattr(-,root,root,-)
%license LICENSE.txt
%doc README.rst docs
%attr(755,root,root) %{_bindir}/pip3*
%{python3_sitelib}/pip*
%endif


%changelog
* Tue Jan 25 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 21.3.1-1
- new upstream release.
- dropped python2 support.

* Tue Feb 23 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.3.4-1
- new upstream release.

* Sat Aug 15 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.2.2-1
- new upstream release.

* Wed Apr 08 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 20.0.2-1
- new upstream release.

* Sat Oct 06 2018 Toshiaki Ara <ara_t@384.jp> 18.1-1
- new upstream release.
- drop Patches
- change URL

* Mon Dec 18 2017 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 9.0.1-1
- new upstream release.
- made to use python{,3}-rpm-macros.
- added a sub-package for python3.

* Sat Jul 26 2014 Toshiharu Kudoh <toshi.kd2@gmail.com> 1.5.6-1
- new upstream release
- didn't rename pip to python-pip

* Sun Jan 12 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.8.1-3
- rebuild with VineSeed environment

* Sun Feb 19 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.8.1-2
- rebuild with python-2.7.2

* Mon Nov 22 2010 Shu KONNO <owa@bg.wakwak.com> 0.8.1-1
- updated pip to 0.8.1

* Fri Sep 03 2010 Daisuke SUZUKI <daisuke@linux.or.jp> 0.8-1
- initial build for Vine Linux

* Mon Aug 30 2010 Peter Halliday <phalliday@excelsiorsystems.net> - 0.8-1
- update to 0.8 of pip
* Thu Jul 22 2010 David Malcolm <dmalcolm@redhat.com> - 0.7.2-5
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild

* Wed Jul 7 2010 Peter Halliday <phalliday@excelsiorsystems.net> - 0.7.2-1
- update to 0.7.2 of pip
* Sun May 23 2010 Peter Halliday <phalliday@excelsiorsystems.net> - 0.7.1-1
- update to 0.7.1 of pip
* Fri Jan 1 2010 Peter Halliday <phalliday@excelsiorsystems.net> - 0.6.1.4
- fix dependency issue
* Fri Dec 18 2009 Peter Halliday <phalliday@excelsiorsystems.net> - 0.6.1-2
- fix spec file 
* Thu Dec 17 2009 Peter Halliday <phalliday@excelsiorsystems.net> - 0.6.1-1
- upgrade to 0.6.1 of pip
* Mon Aug 31 2009 Peter Halliday <phalliday@excelsiorsystems.net> - 0.4-1
- Initial package

