mirror of
https://github.com/python/cpython.git
synced 2025-08-27 04:05:34 +00:00
GH-126985: move pyvenv.cfg detection from site to getpath (#126987)
This commit is contained in:
parent
ab237ff81d
commit
2b0e2b2893
12 changed files with 176 additions and 155 deletions
11
Lib/site.py
11
Lib/site.py
|
@ -94,6 +94,12 @@ def _trace(message):
|
|||
print(message, file=sys.stderr)
|
||||
|
||||
|
||||
def _warn(*args, **kwargs):
|
||||
import warnings
|
||||
|
||||
warnings.warn(*args, **kwargs)
|
||||
|
||||
|
||||
def makepath(*paths):
|
||||
dir = os.path.join(*paths)
|
||||
try:
|
||||
|
@ -619,7 +625,10 @@ def venv(known_paths):
|
|||
elif key == 'home':
|
||||
sys._home = value
|
||||
|
||||
sys.prefix = sys.exec_prefix = site_prefix
|
||||
if sys.prefix != site_prefix:
|
||||
_warn(f'Unexpected value in sys.prefix, expected {site_prefix}, got {sys.prefix}', RuntimeWarning)
|
||||
if sys.exec_prefix != site_prefix:
|
||||
_warn(f'Unexpected value in sys.exec_prefix, expected {site_prefix}, got {sys.exec_prefix}', RuntimeWarning)
|
||||
|
||||
# Doing this here ensures venv takes precedence over user-site
|
||||
addsitepackages(known_paths, [sys.prefix])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue