Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sun, 16 Jan 2022 17:41:00
Message-Id: 1642354848.6254913777f1562b9d614be1ace2795b4e9106f8.mgorny@gentoo
1 commit: 6254913777f1562b9d614be1ace2795b4e9106f8
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Thu Jan 13 09:44:35 2022 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Sun Jan 16 17:40:48 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=62549137
7
8 distutils-r1.eclass: Minimize & unify dift --via-venv logic
9
10 Modify `distutils_install_for_testing --via-venv` to create a minimal
11 venv manually rather than relying on Python to do so. Use root-style
12 install rather than the egg-style to improve consistency with regular
13 installs.
14
15 This is a step towards unifying different install layouts used within
16 the eclass. Right now we support three different variants for testing:
17
18 1. The build-dir layout that's created by python_compile() and exposed
19 unconditionally through PYTHONPATH.
20
21 2. The --via-root layout of dift that resembles install closer
22 (primarily through including package metadata) and also uses
23 PYTHONPATH.
24
25 3. The --via-venv layout of dift that creates a venv and installs
26 the packages there. It requires only PATH, not PYTHONPATH.
27
28 The last layout is the newest and probably the most compatible but it
29 requires additional install step. Since the PEP517 build logic is going
30 to require installing a wheel anyway, the plan is to inject a minimal
31 venv into the staging directory and use it unconditionally for tests.
32
33 The purpose of this patch is to prepare a single code snippet that will
34 be used both by dift and the new logic logic.
35
36 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
37
38 eclass/distutils-r1.eclass | 16 ++++++++++++++--
39 1 file changed, 14 insertions(+), 2 deletions(-)
40
41 diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
42 index 7bd9baba8167..074a611c84dd 100644
43 --- a/eclass/distutils-r1.eclass
44 +++ b/eclass/distutils-r1.eclass
45 @@ -554,14 +554,26 @@ distutils_install_for_testing() {
46 local add_args=()
47
48 if [[ ${install_method} == venv ]]; then
49 - "${EPYTHON}" -m venv --system-site-packages --without-pip \
50 - "${TEST_DIR}" || die
51 + # create a quasi-venv
52 + mkdir -p "${TEST_DIR}"/bin || die
53 + ln -s "${PYTHON}" "${TEST_DIR}/bin/${EPYTHON}" || die
54 + ln -s "${EPYTHON}" "${TEST_DIR}/bin/python3" || die
55 + ln -s "${EPYTHON}" "${TEST_DIR}/bin/python" || die
56 + cat > "${TEST_DIR}"/pyvenv.cfg <<-EOF || die
57 + include-system-site-packages = true
58 + EOF
59
60 # we only do the minimal necessary subset of activate script
61 PATH=${TEST_DIR}/bin:${PATH}
62 # unset PYTHONPATH in order to prevent BUILD_DIR from overriding
63 # venv packages
64 unset PYTHONPATH
65 +
66 + # force root-style install (note: venv adds TEST_DIR to prefixes,
67 + # so we need to pass --root=/)
68 + add_args=(
69 + --root=/
70 + )
71 else
72 local bindir=${TEST_DIR}/scripts
73 local libdir=${TEST_DIR}/lib