commit:     d5d4b491db81d7cfc47093f66dfbd097fc4a2dc2
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 18 19:31:21 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Mar 19 00:05:46 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d5d4b491

dev-lang/python: save/restore PYTHONDONTWRITEBYTECODE for USE=pgo

This avoids writing bytecode when we call has_version (or make
any other calls). But we do need it on for the 'emake' call
when building w/ USE=pgo.

Save & restore the value from the environment before/after
emake if building with PGO.

Closes: https://bugs.gentoo.org/831897
Signed-off-by: Sam James <sam <AT> gentoo.org>
Closes: https://github.com/gentoo/gentoo/pull/24642
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/python/python-3.10.3.ebuild        | 8 ++++++++
 dev-lang/python/python-3.11.0_alpha6.ebuild | 8 ++++++++
 dev-lang/python/python-3.9.11.ebuild        | 8 ++++++++
 3 files changed, 24 insertions(+)

diff --git a/dev-lang/python/python-3.10.3.ebuild 
b/dev-lang/python/python-3.10.3.ebuild
index 478b5c1af9db..8378f90040c5 100644
--- a/dev-lang/python/python-3.10.3.ebuild
+++ b/dev-lang/python/python-3.10.3.ebuild
@@ -236,6 +236,11 @@ src_compile() {
        # https://bugs.gentoo.org/823728
        export SETUPTOOLS_USE_DISTUTILS=stdlib
 
+       # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't
+       # end up writing bytecode & violating sandbox.
+       # bug #831897
+       local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE}
+
        if use pgo ; then
                # bug 660358
                local -x COLUMNS=80
@@ -248,6 +253,9 @@ src_compile() {
        # in _sysconfigdata*
        emake CPPFLAGS= CFLAGS= LDFLAGS=
 
+       # Restore saved value from above.
+       local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE}
+
        # Work around bug 329499. See also bug 413751 and 457194.
        if has_version dev-libs/libffi[pax-kernel]; then
                pax-mark E python

diff --git a/dev-lang/python/python-3.11.0_alpha6.ebuild 
b/dev-lang/python/python-3.11.0_alpha6.ebuild
index ffe6244b6927..ee3604d253a3 100644
--- a/dev-lang/python/python-3.11.0_alpha6.ebuild
+++ b/dev-lang/python/python-3.11.0_alpha6.ebuild
@@ -226,6 +226,11 @@ src_compile() {
        export SETUPTOOLS_USE_DISTUTILS=stdlib
        export PYTHONSTRICTEXTENSIONBUILD=1
 
+       # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't
+       # end up writing bytecode & violating sandbox.
+       # bug #831897
+       local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE}
+
        if use pgo ; then
                # bug 660358
                local -x COLUMNS=80
@@ -238,6 +243,9 @@ src_compile() {
        # in _sysconfigdata*
        emake CPPFLAGS= CFLAGS= LDFLAGS=
 
+       # Restore saved value from above.
+       local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE}
+
        # Work around bug 329499. See also bug 413751 and 457194.
        if has_version dev-libs/libffi[pax-kernel]; then
                pax-mark E python

diff --git a/dev-lang/python/python-3.9.11.ebuild 
b/dev-lang/python/python-3.9.11.ebuild
index a71a3caa791d..418a21b762a8 100644
--- a/dev-lang/python/python-3.9.11.ebuild
+++ b/dev-lang/python/python-3.9.11.ebuild
@@ -221,6 +221,11 @@ src_compile() {
        # https://bugs.gentoo.org/823728
        export SETUPTOOLS_USE_DISTUTILS=stdlib
 
+       # Save PYTHONDONTWRITEBYTECODE so that 'has_version' doesn't
+       # end up writing bytecode & violating sandbox.
+       # bug #831897
+       local -x _PYTHONDONTWRITEBYTECODE=${PYTHONDONTWRITEBYTECODE}
+
        if use pgo ; then
                # bug 660358
                local -x COLUMNS=80
@@ -233,6 +238,9 @@ src_compile() {
        # in _sysconfigdata*
        emake CPPFLAGS= CFLAGS= LDFLAGS=
 
+       # Restore saved value from above.
+       local -x PYTHONDONTWRITEBYTECODE=${_PYTHONDONTWRITEBYTECODE}
+
        # Work around bug 329499. See also bug 413751 and 457194.
        if has_version dev-libs/libffi[pax-kernel]; then
                pax-mark E python

Reply via email to