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.

Signed-off-by: Michał Górny <mgo...@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