Alter the shebangs of generated scripts to point out the to venv Python executables in PEP 517 mode. Otherwise, the executables are run with
system Python during the test run and therefore do not use the venv.
For convenience, rather than modifying them back just copy them
immediately into the python-exec directory. This means that instead of reverting some of our python_compile() changes in python_install()
and then moving scripts to the python-exec directory, we can just
discard /usr/bin and let the wrapping logic recreate it.
While at it, stop repeating ${root}${EPREFIX}/usr/bin multiple times
in python_compile(). Just shove it into a helper variable. Also move pyvenv.cfg inside bindir for convenience — Python is fine with either location.
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 39 +++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 9b2dc841054c..cf3eb639d5e6 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -982,14 +982,30 @@ distutils-r1_python_compile() {
esetup.py clean -a
fi
+ # copy executables to python-exec directory
+ # we do it early so that we can alter bindir recklessly
+ local bindir=${root}${EPREFIX}/usr/bin
+ local rscriptdir=${root}$(python_get_scriptdir)
+ [[ -d ${rscriptdir} ]] &&
+ die "${rscriptdir} should not exist!"
+ if [[ -d ${bindir} ]]; then
+ mkdir -p "${rscriptdir}" || die
+ cp -a --reflink=auto "${bindir}"/. "${rscriptdir}"/ || die
+ fi
+
# enable venv magic inside the install tree
- mkdir -p "${root}${EPREFIX}"/usr/bin || die
- ln -s "${PYTHON}" "${root}${EPREFIX}/usr/bin/${EPYTHON}" || die - ln -s "${EPYTHON}" "${root}${EPREFIX}/u