commit:     3adc7e900eba944aafa51675355df21de79be358
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Sat May 10 12:27:49 2025 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Sat May 10 12:57:14 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3adc7e90

distutils-r1.eclass: Fix pyvenv correctly for Python 3.14

Python 3.14 cleaned up the venv logic, and we have been apparently
relying on some hacks that worked by accident.  More specifically:

1. pyvenv.cfg location is used explicitly as sys.prefix, so we can
   no longer put it inside bin/ subdirectory (no clue why we did that
   -- probably a long chain of historical reasons).

2. "home =" must always be present for venv detection to work.

With these changes, Python 3.14 seems now able to correctly detect
the venv and set prefixes accordingly.  Since they improve correctness,
they should also be fine for other Python versions.

Apparently, the pyvenv.cfg file was moved into bindir back in 2022,
for the trivial reason of using a single directory for all created
files.  Mea culpa!

Fixes: d5b7d1b42500509d31a385fbae77facab02769b7
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 eclass/distutils-r1.eclass | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index cced2b8ffef7..d32e5929177e 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1662,7 +1662,7 @@ distutils-r1_python_install() {
                # let's explicitly verify these assumptions
 
                # remove files that we've created explicitly
-               rm "${reg_scriptdir}"/{"${EPYTHON}",python3,python,pyvenv.cfg} 
|| die
+               rm 
"${reg_scriptdir}"/{"${EPYTHON}",python3,python,../pyvenv.cfg} || die
 
                # Automagically do the QA check to avoid issues when 
bootstrapping
                # prefix.
@@ -2030,9 +2030,11 @@ _distutils-r1_post_python_compile() {
                ln -s "${PYTHON}" "${bindir}/${EPYTHON}" || die
                ln -s "${EPYTHON}" "${bindir}/python3" || die
                ln -s "${EPYTHON}" "${bindir}/python" || die
-               # python3.14t seems to require "home" being present
-               # (though it does not seem to care about the actual value)
-               cat > "${bindir}"/pyvenv.cfg <<-EOF || die
+               # python3.14 changed venv logic so that:
+               # 1) pyvenv.cfg location explicitly determines prefix
+               #    (i.e. we no longer can be put in bin/)
+               # 2) "home =" key must be present
+               cat > "${bindir}"/../pyvenv.cfg <<-EOF || die
                        home = ${EPREFIX}/usr/bin
                        include-system-site-packages = true
                EOF

Reply via email to