%bcond_with bootstrap
%bcond_without python3

%global srcname pip

%global python_wheelname %{srcname}-%{version}-py2.py3-none-any.whl
%if %{without bootstrap}
%global python2_wheelname %python_wheelname
%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:        20.0.2
Release:        1%{?_dist_release}

Group:          Development/Libraries
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
BuildRequires:  python3-rpm-macros
BuildRequires:  python-devel
BuildRequires:  python-setuptools
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools
Requires:       python-setuptools
%if %{without bootstrap}
BuildRequires:  python-pip
BuildRequires:  python-wheel
%endif

Vendor: Project Vine
Distribution: Vine Linux

%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-%{srcname}
Summary:        A tool for installing and managing Python3 packages
Group:          Development/Libraries
%if %{without bootstrap}
BuildRequires:  python3-pip
BuildRequires:  python3-wheel
%endif
Requires:       python3-setuptools

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


%prep
%setup -q -n %{srcname}-%{version}
# %patch0 -p1
# %patch1 -p1

# Remove ordereddict as it is only required for python <= 2.6
#rm pip/_vendor/ordereddict.py

%build
%if %{without bootstrap}
%py_build_wheel
%else
%py_build
%endif

%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

# TODO: we have to remove this by hand now, but it'd be nice if we wouldn't have  to
# (pip install wheel doesn't overwrite)
rm %{buildroot}%{_bindir}/pip
%endif # with python3

%if %{without bootstrap}
%py_install_wheel %{python_wheelname}
%else
%py_install
%endif


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

%files
%defattr(-,root,root,-)
%license LICENSE.txt
%doc README.rst docs
%attr(755,root,root) %{_bindir}/pip
%attr(755,root,root) %{_bindir}/pip2*
%{python_sitelib}/pip*

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


%changelog
* 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