*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / pip / pip-19.3.1-r2.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 PYTHON_COMPAT=( python2_7 python3_{6,7,8} pypy3 )
7 PYTHON_REQ_USE="ssl(+),threads(+)"
8
9 inherit bash-completion-r1 distutils-r1 multiprocessing
10
11 SETUPTOOLS_PV="41.4.0"
12 WHEEL_PV="0.33.6"
13
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/"
16 SRC_URI="
17         https://github.com/pypa/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
18         test? (
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
21         )
22 "
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.
25
26 LICENSE="MIT"
27 KEYWORDS="~amd64 ~arm64 ~sparc ~x86"
28 SLOT="0"
29 IUSE="test -vanilla"
30
31 # disable-system-install patch breaks tests
32 RESTRICT="!test? ( test )"
33
34 RDEPEND="
35         >=dev-python/setuptools-39.2.0[${PYTHON_USEDEP}]
36 "
37 DEPEND="
38         ${RDEPEND}
39         test? (
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}]
48         )
49 "
50
51 python_prepare_all() {
52         local PATCHES=(
53                 "${FILESDIR}/${PN}-19.3-disable-version-check.patch"
54
55                 # these are from upstream git
56                 "${FILESDIR}/pip-19.3.1-network-tests.patch"
57         )
58         if ! use vanilla; then
59                 PATCHES+=( "${FILESDIR}/pip-19.3.1-r2-disable-system-install.patch" )
60         fi
61         distutils-r1_python_prepare_all
62
63         if use test; then
64                 mkdir tests/data/common_wheels/ || die
65                 cp "${DISTDIR}"/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl \
66                         tests/data/common_wheels/ || die
67
68                 cp "${DISTDIR}"/wheel-${WHEEL_PV}-py2.py3-none-any.whl \
69                         tests/data/common_wheels/ || die
70         fi
71 }
72
73 python_test() {
74         if [[ ${EPYTHON} == pypy* ]]; then
75                 ewarn "Skipping tests on ${EPYTHON} since they are very broken"
76                 return 0
77         fi
78
79         local -a exclude_tests
80
81         # these will be built in to an expression passed to pytest to exclude
82         exclude_tests=(
83                 git
84                 svn
85                 bazaar
86                 mercurial
87                 version_check
88                 uninstall_non_local_distutils
89                 pep518_uses_build_env
90                 install_package_with_root
91                 install_editable_with_prefix
92                 install_user_wheel
93                 install_from_current_directory_into_usersite
94                 uninstall_editable_from_usersite
95                 uninstall_from_usersite_with_dist_in_global_site
96                 build_env_isolation
97         )
98
99         distutils_install_for_testing
100
101         # generate the expression to exclude failing tests
102         local exclude_expr
103         printf -v exclude_expr "or %s " "${exclude_tests[@]}" || die
104         exclude_expr="not (${exclude_expr#or })" || die
105
106         local -x GENTOO_PIP_TESTING=1 \
107                 PATH="${TEST_DIR}/scripts:${PATH}" \
108                 PYTHONPATH="${TEST_DIR}/lib:${BUILD_DIR}/lib"
109
110         pytest -vv \
111                 -k "${exclude_expr}" \
112                 -m "not network" \
113                 || die "Tests fail with ${EPYTHON}"
114 }
115
116 python_install_all() {
117         local DOCS=( AUTHORS.txt docs/html/**/*.rst )
118         distutils-r1_python_install_all
119
120         COMPLETION="${T}"/completion.tmp
121
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())'
126
127         ${PYTHON} -c "${pipcmd}" completion --bash > "${COMPLETION}" || die
128         newbashcomp "${COMPLETION}" ${PN}
129
130         ${PYTHON} -c "${pipcmd}" completion --zsh > "${COMPLETION}" || die
131         insinto /usr/share/zsh/site-functions
132         newins "${COMPLETION}" _pip
133 }