Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: python@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/4] distutils-r1.eclass: Introduce install_for_testing --via-root
Date: Sat, 28 Nov 2020 23:51:19
Message-Id: 20201128235104.52278-1-mgorny@gentoo.org
1 Introduce a new --via-root mode for distutils_install_for_testing
2 function. The legacy --via-home seems to no longer work for a lot
3 of packages but before we can confirm that --via-root is good enough
4 for every single one of them, let's have two variants to choose from.
5
6 The general recommendation is to try --via-root, and explicitly specify
7 --via-home if the former does not work. Once all packages have explicit
8 --via-*, we will decide how to proceed.
9
10 Signed-off-by: Michał Górny <mgorny@g.o>
11 ---
12 eclass/distutils-r1.eclass | 50 +++++++++++++++++++++++++++++++-------
13 1 file changed, 41 insertions(+), 9 deletions(-)
14
15 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
16 index 25cb67b78a31..9e862a949275 100644
17 --- a/eclass/distutils-r1.eclass
18 +++ b/eclass/distutils-r1.eclass
19 @@ -492,7 +492,7 @@ esetup.py() {
20 }
21
22 # @FUNCTION: distutils_install_for_testing
23 -# @USAGE: [<args>...]
24 +# @USAGE: [--via-root|--via-home] [<args>...]
25 # @DESCRIPTION:
26 # Install the package into a temporary location for running tests.
27 # Update PYTHONPATH appropriately and set TEST_DIR to the test
28 @@ -503,11 +503,19 @@ esetup.py() {
29 # namespaces (and therefore proper install needs to be done to enforce
30 # PYTHONPATH) or tests rely on the results of install command.
31 # For most of the packages, tests built in BUILD_DIR are good enough.
32 +#
33 +# The function supports two install modes. The current default is
34 +# the legacy --via-home mode. However, it has problems with newer
35 +# versions of setuptools (50.3.0+). The --via-root mode generally
36 +# works for these packages, and it will probably become the default
37 +# in the future, once we test all affected packages. Please note
38 +# that proper testing sometimes requires unmerging the package first.
39 distutils_install_for_testing() {
40 debug-print-function ${FUNCNAME} "${@}"
41
42 # A few notes:
43 - # 1) because of namespaces, we can't use 'install --root',
44 + # 1) because of namespaces, we can't use 'install --root'
45 + # (NB: this is probably no longer true with py3),
46 # 2) 'install --home' is terribly broken on pypy, so we need
47 # to override --install-lib and --install-scripts,
48 # 3) non-root 'install' complains about PYTHONPATH and missing dirs,
49 @@ -522,14 +530,38 @@ distutils_install_for_testing() {
50 PATH=${bindir}:${PATH}
51 PYTHONPATH=${libdir}:${PYTHONPATH}
52
53 - local add_args=(
54 - install
55 - --home="${TEST_DIR}"
56 - --install-lib="${libdir}"
57 - --install-scripts="${bindir}"
58 - )
59 + local install_method=home
60 + case ${1} in
61 + --via-home)
62 + install_method=home
63 + shift
64 + ;;
65 + --via-root)
66 + install_method=root
67 + shift
68 + ;;
69 + esac
70 +
71 + case ${install_method} in
72 + home)
73 + local add_args=(
74 + install
75 + --home="${TEST_DIR}"
76 + --install-lib="${libdir}"
77 + --install-scripts="${bindir}"
78 + )
79 + mkdir -p "${libdir}" || die
80 + ;;
81 + root)
82 + local add_args=(
83 + install
84 + --root="${TEST_DIR}"
85 + --install-lib=lib
86 + --install-scripts=scripts
87 + )
88 + ;;
89 + esac
90
91 - mkdir -p "${libdir}" || die
92 esetup.py "${add_args[@]}" "${@}"
93 }
94
95 --
96 2.29.2

Replies