* [gentoo-dev] [PATCH] distutils-r1.eclass: Minimize & unify dift --via-venv logic
@ 2022-01-13 10:29 Michał Górny
0 siblings, 0 replies; only message in thread
From: Michał Górny @ 2022-01-13 10:29 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Modify `distutils_install_for_testing --via-venv` to create a minimal
venv manually rather than relying on Python to do so. Use root-style
install rather than the egg-style to improve consistency with regular
installs.
This is a step towards unifying different install layouts used within
the eclass. Right now we support three different variants for testing:
1. The build-dir layout that's created by python_compile() and exposed
unconditionally through PYTHONPATH.
2. The --via-root layout of dift that resembles install closer
(primarily through including package metadata) and also uses
PYTHONPATH.
3. The --via-venv layout of dift that creates a venv and installs
the packages there. It requires only PATH, not PYTHONPATH.
The last layout is the newest and probably the most compatible but it
requires additional install step. Since the PEP517 build logic is going
to require installing a wheel anyway, the plan is to inject a minimal
venv into the staging directory and use it unconditionally for tests.
The purpose of this patch is to prepare a single code snippet that will
be used both by dift and the new logic logic.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 7bd9baba8167..074a611c84dd 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -554,14 +554,26 @@ distutils_install_for_testing() {
local add_args=()
if [[ ${install_method} == venv ]]; then
- "${EPYTHON}" -m venv --system-site-packages --without-pip \
- "${TEST_DIR}" || die
+ # create a quasi-venv
+ mkdir -p "${TEST_DIR}"/bin || die
+ ln -s "${PYTHON}" "${TEST_DIR}/bin/${EPYTHON}" || die
+ ln -s "${EPYTHON}" "${TEST_DIR}/bin/python3" || die
+ ln -s "${EPYTHON}" "${TEST_DIR}/bin/python" || die
+ cat > "${TEST_DIR}"/pyvenv.cfg <<-EOF || die
+ include-system-site-packages = true
+ EOF
# we only do the minimal necessary subset of activate script
PATH=${TEST_DIR}/bin:${PATH}
# unset PYTHONPATH in order to prevent BUILD_DIR from overriding
# venv packages
unset PYTHONPATH
+
+ # force root-style install (note: venv adds TEST_DIR to prefixes,
+ # so we need to pass --root=/)
+ add_args=(
+ --root=/
+ )
else
local bindir=${TEST_DIR}/scripts
local libdir=${TEST_DIR}/lib
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-13 10:30 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-13 10:29 [gentoo-dev] [PATCH] distutils-r1.eclass: Minimize & unify dift --via-venv logic Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox