You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New site.py implementation fails to load .pth files in subprocesses #149819
After #149583, .pth files are no longer loaded in Python subprocesses, as started with subprocess.run([sys.executable, …]) and the like.
The new implementation deliberately ignores .pth files in sys.path directories that are already known, and Python subprocesses already know all the paths of their parent process. Thus, all .pth files in those paths are ignored by subprocesses now.
I specifically noticed this when running setuptools in a build subprocess, which now fails to install its distutils replacement hack.
changed the title [-]New site.py implementations fails fails to load .pth files in subprocesses[/-][+]New site.py implementations fails to load .pth files in subprocesses[/+]on May 14, 2026
Traceback (most recent call last):
File "…/TEST_TMP/compile/declarations/setup.py", line 2, in <module>
from distutils.core import setup
ModuleNotFoundError: No module named 'distutils'
I was using CPython's main branch at f1a47e7 for this (that's shortly after #149659 was merged).
Could you please try again with 87a879f from main or ad2f0cb from the 3.15 branch? I tried your recipe in both and it still WFM. It probably doesn't matter, but I'm on macOS.
% python3 runtests.py --debug "compile\.declarations"
Python 3.15.0b1+ (heads/3.15:ad2f0cb997a, May 20 2026, 10:11:23) [Clang 21.0.0 (clang-2100.1.1.101)]
Running tests against Cython 3.3.0a0 7eeaf92d5d0c5ee1c2964566856b4d0568e8532c
Using Cython language level 2.
Test dependency not found: 'numpy'
Test dependency not found: 'pythran'
Test dependency not found: 'setuptools.sandbox'
Test dependency found: 'asyncio' version 3.15.0b1+
Test dependency found: 'pstats' version 3.15.0b1+
Test dependency found: 'posix' version 3.15.0b1+
Test dependency found: 'array' version ?.?
Test dependency not found: 'Cython.Coverage'
Test dependency not found: 'Cython.Coverage'
Test dependency not found: 'IPython.testing.globalipapp'
Test dependency not found: 'jedi_BROKEN_AND_DISABLED'
Test dependency found: 'test.support' version 3.15.0b1+
Backends: c,cpp
[etoe.declarations: SLOWTEST 0.88 sec] ----------------------------------------------------------------------
Ran 1 test in 0.888s
OK
Most expensive pipeline stages: 'AnalyseDeclarationsTransform': 0.15 / 8 (0.019 / run, 54.2%), 'parse': 0.03 / 8 (0.004 / run, 12.4%), 'generate_pyx_code_stage': 0.03 / 1 (0.031 / run, 11.1%), 'AnalyseExpressionsTransform': 0.01 / 8 (0.001 / run, 3.7%), 'PostParse': 0.01 / 8 (0.001 / run, 1.9%), 'OptimizeBuiltinCalls': 0.00 / 8 (0.001 / run, 1.6%), 'RemoveUnreachableCode': 0.00 / 16 (0.000 / run, 1.4%), 'InterpretCompilerDirectives': 0.00 / 8 (0.000 / run, 1.0%), 'MarkClosureVisitor': 0.00 / 8 (0.000 / run, 0.9%), 'ControlFlowAnalysis': 0.00 / 8 (0.000 / run, 0.9%)
Times:
etoe-build : 0.66 sec ( 1, 0.663 / run) - slowest: 'c:declarations(1)' (0.66s)
etoe-run : 0.22 sec ( 1, 0.217 / run) - slowest: 'c:declarations(2)' (0.22s)
ALL DONE
I tried with latest main (87a879f) and it fails for me, as before. This is on Ubuntu Linux. We don't have "latest main" integration tests running on anything else, so I can't compare right now. But your failure to reproduce it speaks for a platform specific issue. Possibly some spawn/fork/exec kind of difference?
changed the title [-]New site.py implementations fails to load .pth files in subprocesses[/-][+]New site.py implementation fails to load .pth files in subprocesses[/+]on May 21, 2026
Activity
[-]New site.py implementations fails fails to load .pth files in subprocesses[/-][+]New site.py implementations fails to load .pth files in subprocesses[/+]warsaw commentedon May 15, 2026
It works for me with the following test script.
This outputs:
warsaw commentedon May 15, 2026
This is using the head of the 3.15 branch 21909e8
pythongh-149819: Fix .pth files not loaded in Python subprocesses
warsaw commentedon May 18, 2026
Closing as Can't Reproduce.
scoder commentedon May 19, 2026
Don't expect everyone else to work 24/7 on fixing other people's code. :]
Here's the easy (for me) reproducer:
Fails in a file that the test run generates with
I was using CPython's main branch at f1a47e7 for this (that's shortly after #149659 was merged).
warsaw commentedon May 20, 2026
Could you please try again with 87a879f from
mainor ad2f0cb from the3.15branch? I tried your recipe in both and it still WFM. It probably doesn't matter, but I'm on macOS.scoder commentedon May 20, 2026
I tried with latest main (87a879f) and it fails for me, as before. This is on Ubuntu Linux. We don't have "latest main" integration tests running on anything else, so I can't compare right now. But your failure to reproduce it speaks for a platform specific issue. Possibly some spawn/fork/exec kind of difference?
Merge branch 'main' into pythongh-149819-fix-pth-subprocess
warsaw commentedon May 21, 2026
Please review the latest linked PR
scoder commentedon May 21, 2026
Tried it, works for me, resolves this issue.
[-]New site.py implementations fails to load .pth files in subprocesses[/-][+]New site.py implementation fails to load .pth files in subprocesses[/+]Merge branch 'main' into pythongh-149819-fix-pth-subprocess
gh-149819: fix .pth and .start file processing in subprocess when inh…
[3.15] gh-149819: fix .pth and .start file processing in subprocess w…
warsaw commentedon May 21, 2026
Fixed in
mainand 3.15 (it should show up in the next beta). Thanks again!