dev-python/pip: keyworded 20.1.1 for ia64, bug #719700
[gentoo.git] / dev-python / pip / pip-20.1.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 DISTUTILS_USE_SETUPTOOLS=rdepend
7 PYTHON_COMPAT=( python2_7 python3_{6,7,8,9} pypy3 )
8 PYTHON_REQ_USE="ssl(+),threads(+)"
9
10 inherit bash-completion-r1 distutils-r1 multiprocessing
11
12 SETUPTOOLS_PV="44.0.0"
13 WHEEL_PV="0.34.2"
14
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/"
17 SRC_URI="
18         https://github.com/pypa/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz
19         test? (
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
22         )
23 "
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.
26
27 LICENSE="MIT"
28 KEYWORDS="~amd64 ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~sparc ~x86"
29 SLOT="0"
30 IUSE="test -vanilla"
31
32 # disable-system-install patch breaks tests
33 RESTRICT="!test? ( test )"
34
35 RDEPEND="
36         >=dev-python/setuptools-39.2.0[${PYTHON_USEDEP}]
37 "
38 DEPEND="
39         ${RDEPEND}
40         test? (
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)
53         )
54 "
55
56 python_prepare_all() {
57         local PATCHES=(
58                 "${FILESDIR}/${PN}-19.3-disable-version-check.patch"
59                 "${FILESDIR}/${P}-test-endian.patch"
60         )
61         if ! use vanilla; then
62                 PATCHES+=( "${FILESDIR}/pip-20.0.2-disable-system-install.patch" )
63         fi
64         distutils-r1_python_prepare_all
65
66         if use test; then
67                 mkdir tests/data/common_wheels/ || die
68                 cp "${DISTDIR}"/setuptools-${SETUPTOOLS_PV}-py2.py3-none-any.whl \
69                         tests/data/common_wheels/ || die
70
71                 cp "${DISTDIR}"/wheel-${WHEEL_PV}-py2.py3-none-any.whl \
72                         tests/data/common_wheels/ || die
73         fi
74 }
75
76 python_test() {
77         if [[ ${EPYTHON} == pypy* ]]; then
78                 ewarn "Skipping tests on ${EPYTHON} since they are very broken"
79                 return 0
80         fi
81
82         local -a exclude_tests
83
84         # these will be built in to an expression passed to pytest to exclude
85         exclude_tests=(
86                 git
87                 svn
88                 bazaar
89                 mercurial
90                 version_check
91                 uninstall_non_local_distutils
92                 pep518_uses_build_env
93                 install_package_with_root
94                 install_editable_with_prefix
95                 install_user_wheel
96                 install_from_current_directory_into_usersite
97                 uninstall_editable_from_usersite
98                 uninstall_from_usersite_with_dist_in_global_site
99                 build_env_isolation
100                 user_config_accepted
101         )
102
103         distutils_install_for_testing
104
105         # generate the expression to exclude failing tests
106         local exclude_expr
107         printf -v exclude_expr "or %s " "${exclude_tests[@]}" || die
108         exclude_expr="not (${exclude_expr#or })" || die
109
110         local -x GENTOO_PIP_TESTING=1 \
111                 PATH="${TEST_DIR}/scripts:${PATH}" \
112                 PYTHONPATH="${TEST_DIR}/lib:${BUILD_DIR}/lib"
113
114         pytest -vv \
115                 -k "${exclude_expr}" \
116                 -m "not network" \
117                 || die "Tests fail with ${EPYTHON}"
118 }
119
120 python_install_all() {
121         # Prevent dbus auto-launch
122         # https://bugs.gentoo.org/692178
123         export DBUS_SESSION_BUS_ADDRESS="disabled:"
124
125         local DOCS=( AUTHORS.txt docs/html/**/*.rst )
126         distutils-r1_python_install_all
127
128         COMPLETION="${T}"/completion.tmp
129
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())'
134
135         ${PYTHON} -c "${pipcmd}" completion --bash > "${COMPLETION}" || die
136         newbashcomp "${COMPLETION}" ${PN}
137
138         ${PYTHON} -c "${pipcmd}" completion --zsh > "${COMPLETION}" || die
139         insinto /usr/share/zsh/site-functions
140         newins "${COMPLETION}" _pip
141 }