*/*: Clean PYTHON_COMPAT of obsolete impls
[gentoo.git] / dev-python / pip / pip-19.1.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} pypy3 )
7 PYTHON_REQ_USE="ssl(+),threads(+)"
8
9 inherit bash-completion-r1 distutils-r1 multiprocessing
10
11 SETUPTOOLS_PV="41.0.1"
12 WHEEL_PV="0.33.1"
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 x86"
28 SLOT="0"
29 IUSE="test -vanilla"
30
31 # disable-system-install patch breaks tests
32 RESTRICT="!vanilla? ( test ) !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-4[${PYTHON_USEDEP}]
44                 dev-python/pytest-cov[${PYTHON_USEDEP}]
45                 <dev-python/pytest-rerunfailures-7.0[${PYTHON_USEDEP}]
46                 dev-python/pytest-timeout[${PYTHON_USEDEP}]
47                 <dev-python/pytest-xdist-1.28.0[${PYTHON_USEDEP}]
48                 dev-python/pyyaml[${PYTHON_USEDEP}]
49                 dev-python/scripttest[${PYTHON_USEDEP}]
50                 dev-python/wheel[${PYTHON_USEDEP}]
51         )
52 "
53
54 python_prepare_all() {
55         local PATCHES=(
56                 "${FILESDIR}/${PN}-19.1-disable-version-check.patch"
57         )
58         if ! use vanilla; then
59                 PATCHES+=( "${FILESDIR}/pip-19.1-disable-system-install.patch" )
60         fi
61         distutils-r1_python_prepare_all
62
63         if use test; then
64                 mkdir tests/data/common_wheels/
65                 cp "${DISTDIR}"/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl tests/data/common_wheels/ || die
66                 cp "${DISTDIR}"/wheel-${WHEEL_PV}-py2.py3-none-any.whl tests/data/common_wheels/ || die
67         fi
68 }
69
70 python_test () {
71         # Exclude tests that fail for some reason. Some of these failures may be Gentoo-specific.
72         python -m pytest \
73                 -n $(makeopts_jobs) \
74                 --timeout 300 \
75                 -k "not (svn or git or bazaar or mercurial or test_pep518_uses_build_env or test_install_package_with_root or test_install_editable_with_prefix or install_from_user or install_user_conflict or upgrade_user_conflict or build_env_isolation or config_file_venv_option or get_legacy_build_wheel or install_user_wheel or uninstall_non_local_distutils or install_from_current_directory_into_usersite or uninstall_editable_from_usersite)" \
76                 -m "not network" \
77                 || die
78 }
79
80 python_install_all() {
81         local DOCS=( AUTHORS.txt docs/html/**/*.rst )
82         distutils-r1_python_install_all
83
84         COMPLETION="${T}"/completion.tmp
85
86         # 'pip completion' command embeds full $0 into completion script, which confuses
87         # 'complete' and causes QA warning when running as "${PYTHON} -m pip".
88         # This trick sets correct $0 while still calling just installed pip.
89         local pipcmd='import sys; sys.argv[0] = "pip"; import pip.__main__; sys.exit(pip.__main__._main())'
90
91         ${PYTHON} -c "${pipcmd}" completion --bash > "${COMPLETION}" || die
92         newbashcomp "${COMPLETION}" ${PN}
93
94         ${PYTHON} -c "${pipcmd}" completion --zsh > "${COMPLETION}" || die
95         insinto /usr/share/zsh/site-functions
96         newins "${COMPLETION}" _pip
97 }