File python-pip.spec of Package python-pip

# spec file for package python-pip
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via

%{?!python_module:%define python_module() python-%{**} python3-%{**}}
# NOTE(saschpe): git invocation and pythonpath issues with testrepository
# enable testing with a build conditional (off by default):
%bcond_with test
Name:           python-pip
Version:        18.0
Release:        0
Summary:        Pip installs packages. Python packages. An easy_install replacement
License:        MIT
Group:          Development/Languages/Python
Patch0:         pip-8.1.2-shipped-requests-cabundle.patch
BuildRequires:  %{python_module devel}
BuildRequires:  %{python_module setuptools}
BuildRequires:  fdupes
BuildRequires:  python-rpm-macros
Requires:       ca-certificates
Requires:       coreutils
Requires:       python-setuptools
Requires:       python-xml
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends:     ca-certificates-mozilla
BuildArch:      noarch
%if %{with test}
# Test requirements:
BuildRequires:  %{python_module docutils}
BuildRequires:  %{python_module freezegun}
BuildRequires:  %{python_module mock}
BuildRequires:  %{python_module pretend}
BuildRequires:  %{python_module pytest}
BuildRequires:  %{python_module scripttest >= 1.3}
BuildRequires:  %{python_module virtualenv >= 1.10}

Pip is a replacement for easy_install. It uses mostly the same techniques for
finding packages, so packages that were made easy_installable should be
pip-installable as well.

%setup -q -n pip-%{version}
%patch0 -p1
find src/pip/_vendor -name *.py -exec \
    sed -i "s|#!%{_bindir}/env python||g" {} ";" # Fix non-executable script
#sed -i "s|#!/usr/bin/env python||g" pip/ # Fix non-executable script
rm src/pip/_vendor/certifi/cacert.pem


%prepare_alternative pip
%fdupes %{buildroot}%{_prefix}

%if %{with test}
%python_expand py.test-%{$python_version}

# Since /usr/bin/pip became ghosted to be used with update-alternatives, we have to get rid
# of the old binary resulting from the non-update-alternatives-ified package:
[ -h %{_bindir}/pip ] || rm -f %{_bindir}/pip

# can't use `python_install_alternative` because it's pipX.Y, not pip-X.Y
PRIO=$(echo %{python_version} | tr -d .)
%install_alternative pip %{_bindir}/pip-%{pypy3_bin_suffix} $PRIO
%install_alternative pip %{_bindir}/pip%{python_version} $PRIO

%uninstall_alternative pip %{_bindir}/pip-%{pypy3_bin_suffix}
%uninstall_alternative pip %{_bindir}/pip%{python_version}

%files %{python_files}
%license LICENSE.txt
%doc AUTHORS.txt NEWS.rst README.rst
%python2_only %{_bindir}/pip2
%python3_only %{_bindir}/pip3
%ghost %{_sysconfdir}/alternatives/pip