1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 DISTUTILS_USE_SETUPTOOLS=rdepend
7 PYTHON_COMPAT=( python2_7 python3_{6,7,8,9} pypy3 )
8 PYTHON_REQ_USE="ssl(+),threads(+)"
10 inherit bash-completion-r1 distutils-r1 multiprocessing
12 SETUPTOOLS_PV="44.0.0"
15 DESCRIPTION="Installs python packages -- replacement for easy_install"
16 HOMEPAGE="https://pip.pypa.io/ https://pypi.org/project/pip/ https://github.com/pypa/pip/"
18 https://github.com/pypa/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
20 https://files.pythonhosted.org/packages/py2.py3/s/setuptools/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl
21 https://files.pythonhosted.org/packages/py2.py3/w/wheel/wheel-${WHEEL_PV}-py2.py3-none-any.whl
24 # PyPI archive does not have tests, so we need to download from GitHub.
25 # setuptools & wheel .whl files are required for testing, exact version is not very important.
28 KEYWORDS="~amd64 ~arm64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
32 # disable-system-install patch breaks tests
33 RESTRICT="!test? ( test )"
36 >=dev-python/setuptools-39.2.0[${PYTHON_USEDEP}]
41 dev-python/cryptography[${PYTHON_USEDEP}]
42 dev-python/csv23[${PYTHON_USEDEP}]
43 dev-python/freezegun[${PYTHON_USEDEP}]
44 dev-python/mock[${PYTHON_USEDEP}]
45 dev-python/pretend[${PYTHON_USEDEP}]
46 dev-python/pytest[${PYTHON_USEDEP}]
47 dev-python/pyyaml[${PYTHON_USEDEP}]
48 dev-python/scripttest[${PYTHON_USEDEP}]
49 <dev-python/virtualenv-20[${PYTHON_USEDEP}]
50 dev-python/werkzeug[${PYTHON_USEDEP}]
51 dev-python/wheel[${PYTHON_USEDEP}]
52 $(python_gen_cond_dep 'dev-python/enum34[${PYTHON_USEDEP}]' -2)
56 python_prepare_all() {
58 "${FILESDIR}/${PN}-19.3-disable-version-check.patch"
59 "${FILESDIR}/${P}-test-endian.patch"
61 if ! use vanilla; then
62 PATCHES+=( "${FILESDIR}/pip-20.0.2-disable-system-install.patch" )
64 distutils-r1_python_prepare_all
67 mkdir tests/data/common_wheels/ || die
68 cp "${DISTDIR}"/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl \
69 tests/data/common_wheels/ || die
71 cp "${DISTDIR}"/wheel-${WHEEL_PV}-py2.py3-none-any.whl \
72 tests/data/common_wheels/ || die
77 if [[ ${EPYTHON} == pypy* ]]; then
78 ewarn "Skipping tests on ${EPYTHON} since they are very broken"
82 local -a exclude_tests
84 # these will be built in to an expression passed to pytest to exclude
91 uninstall_non_local_distutils
93 install_package_with_root
94 install_editable_with_prefix
96 install_from_current_directory_into_usersite
97 uninstall_editable_from_usersite
98 uninstall_from_usersite_with_dist_in_global_site
103 distutils_install_for_testing
105 # generate the expression to exclude failing tests
107 printf -v exclude_expr "or %s " "${exclude_tests[@]}" || die
108 exclude_expr="not (${exclude_expr#or })" || die
110 local -x GENTOO_PIP_TESTING=1 \
111 PATH="${TEST_DIR}/scripts:${PATH}" \
112 PYTHONPATH="${TEST_DIR}/lib:${BUILD_DIR}/lib"
115 -k "${exclude_expr}" \
117 || die "Tests fail with ${EPYTHON}"
120 python_install_all() {
121 # Prevent dbus auto-launch
122 # https://bugs.gentoo.org/692178
123 export DBUS_SESSION_BUS_ADDRESS="disabled:"
125 local DOCS=( AUTHORS.txt docs/html/**/*.rst )
126 distutils-r1_python_install_all
128 COMPLETION="${T}"/completion.tmp
130 # 'pip completion' command embeds full $0 into completion script, which confuses
131 # 'complete' and causes QA warning when running as "${PYTHON} -m pip".
132 # This trick sets correct $0 while still calling just installed pip.
133 local pipcmd='import sys; sys.argv[0] = "pip"; import pip.__main__; sys.exit(pip.__main__._main())'
135 ${PYTHON} -c "${pipcmd}" completion --bash > "${COMPLETION}" || die
136 newbashcomp "${COMPLETION}" ${PN}
138 ${PYTHON} -c "${pipcmd}" completion --zsh > "${COMPLETION}" || die
139 insinto /usr/share/zsh/site-functions
140 newins "${COMPLETION}" _pip