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