1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 PYTHON_COMPAT=( python2_7 python3_{6,7,8} pypy3 )
7 PYTHON_REQ_USE="ssl(+),threads(+)"
9 inherit bash-completion-r1 distutils-r1 multiprocessing
11 SETUPTOOLS_PV="41.4.0"
14 DESCRIPTION="Installs python packages -- replacement for easy_install"
15 HOMEPAGE="https://pip.pypa.io/ https://pypi.org/project/pip/ https://github.com/pypa/pip/"
17 https://github.com/pypa/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
19 https://files.pythonhosted.org/packages/py2.py3/s/setuptools/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl
20 https://files.pythonhosted.org/packages/py2.py3/w/wheel/wheel-${WHEEL_PV}-py2.py3-none-any.whl
23 # PyPI archive does not have tests, so we need to download from GitHub.
24 # setuptools & wheel .whl files are required for testing, exact version is not very important.
27 KEYWORDS="~amd64 ~arm64 ~sparc ~x86"
31 # disable-system-install patch breaks tests
32 RESTRICT="!test? ( test )"
35 >=dev-python/setuptools-39.2.0[${PYTHON_USEDEP}]
40 dev-python/freezegun[${PYTHON_USEDEP}]
41 dev-python/mock[${PYTHON_USEDEP}]
42 dev-python/pretend[${PYTHON_USEDEP}]
43 dev-python/pytest[${PYTHON_USEDEP}]
44 dev-python/pyyaml[${PYTHON_USEDEP}]
45 dev-python/scripttest[${PYTHON_USEDEP}]
46 dev-python/virtualenv[${PYTHON_USEDEP}]
47 dev-python/wheel[${PYTHON_USEDEP}]
51 python_prepare_all() {
53 "${FILESDIR}/${PN}-19.3-disable-version-check.patch"
55 # these are from upstream git
56 "${FILESDIR}/pip-19.3.1-network-tests.patch"
58 if ! use vanilla; then
59 PATCHES+=( "${FILESDIR}/pip-19.3.1-r2-disable-system-install.patch" )
61 distutils-r1_python_prepare_all
64 mkdir tests/data/common_wheels/ || die
65 cp "${DISTDIR}"/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl \
66 tests/data/common_wheels/ || die
68 cp "${DISTDIR}"/wheel-${WHEEL_PV}-py2.py3-none-any.whl \
69 tests/data/common_wheels/ || die
74 if [[ ${EPYTHON} == pypy* ]]; then
75 ewarn "Skipping tests on ${EPYTHON} since they are very broken"
79 local -a exclude_tests
81 # these will be built in to an expression passed to pytest to exclude
88 uninstall_non_local_distutils
90 install_package_with_root
91 install_editable_with_prefix
93 install_from_current_directory_into_usersite
94 uninstall_editable_from_usersite
95 uninstall_from_usersite_with_dist_in_global_site
99 distutils_install_for_testing
101 # generate the expression to exclude failing tests
103 printf -v exclude_expr "or %s " "${exclude_tests[@]}" || die
104 exclude_expr="not (${exclude_expr#or })" || die
106 local -x GENTOO_PIP_TESTING=1 \
107 PATH="${TEST_DIR}/scripts:${PATH}" \
108 PYTHONPATH="${TEST_DIR}/lib:${BUILD_DIR}/lib"
111 -k "${exclude_expr}" \
113 || die "Tests fail with ${EPYTHON}"
116 python_install_all() {
117 local DOCS=( AUTHORS.txt docs/html/**/*.rst )
118 distutils-r1_python_install_all
120 COMPLETION="${T}"/completion.tmp
122 # 'pip completion' command embeds full $0 into completion script, which confuses
123 # 'complete' and causes QA warning when running as "${PYTHON} -m pip".
124 # This trick sets correct $0 while still calling just installed pip.
125 local pipcmd='import sys; sys.argv[0] = "pip"; import pip.__main__; sys.exit(pip.__main__._main())'
127 ${PYTHON} -c "${pipcmd}" completion --bash > "${COMPLETION}" || die
128 newbashcomp "${COMPLETION}" ${PN}
130 ${PYTHON} -c "${pipcmd}" completion --zsh > "${COMPLETION}" || die
131 insinto /usr/share/zsh/site-functions
132 newins "${COMPLETION}" _pip