From 07cf9fcbe952182643f9f82c59717286881ddb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Tue, 18 Jun 2024 11:20:36 +0200 Subject: [PATCH] Disable system site-packages via GENTOO_CPYTHON_BUILD var MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not add system site-packages directory to sys.path if GENTOO_CPYTHON_BUILD variable is set. This solves multiple issues while building and testing CPython, particularly test suite issues from installed .pth files, Python modules (particularly docutils) and sandbox violations from attempting to write byte-compiled modules back. Signed-off-by: Michał Górny --- Lib/site.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/site.py b/Lib/site.py index 0a0dc47b174d47..6ab0a31f679ede 100644 --- a/Lib/site.py +++ b/Lib/site.py @@ -415,6 +415,7 @@ def getsitepackages(prefixes=None): def addsitepackages(known_paths, prefixes=None): """Add site-packages to sys.path""" + if os.environ.get("GENTOO_CPYTHON_BUILD") and prefixes is None: return known_paths _trace("Processing global site-packages") for sitedir in getsitepackages(prefixes): if os.path.isdir(sitedir):