mirror of https://github.com/python/cpython
gh-101543: Ensure Windows registry path is only used when stdlib can't be found (GH-101544)
This commit is contained in:
parent
46416b9004
commit
7a253103d4
|
@ -0,0 +1,2 @@
|
||||||
|
Ensure the install path in the registry is only used when the standard
|
||||||
|
library hasn't been located in any other way.
|
|
@ -582,7 +582,7 @@ else:
|
||||||
# Detect prefix by searching from our executable location for the stdlib_dir
|
# Detect prefix by searching from our executable location for the stdlib_dir
|
||||||
if STDLIB_SUBDIR and STDLIB_LANDMARKS and executable_dir and not prefix:
|
if STDLIB_SUBDIR and STDLIB_LANDMARKS and executable_dir and not prefix:
|
||||||
prefix = search_up(executable_dir, *STDLIB_LANDMARKS)
|
prefix = search_up(executable_dir, *STDLIB_LANDMARKS)
|
||||||
if prefix:
|
if prefix and not stdlib_dir:
|
||||||
stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
|
stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
|
||||||
|
|
||||||
if PREFIX and not prefix:
|
if PREFIX and not prefix:
|
||||||
|
@ -631,20 +631,6 @@ else:
|
||||||
warn('Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]')
|
warn('Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]')
|
||||||
|
|
||||||
|
|
||||||
# If we haven't set [plat]stdlib_dir already, set them now
|
|
||||||
if not stdlib_dir:
|
|
||||||
if prefix:
|
|
||||||
stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
|
|
||||||
else:
|
|
||||||
stdlib_dir = ''
|
|
||||||
|
|
||||||
if not platstdlib_dir:
|
|
||||||
if exec_prefix:
|
|
||||||
platstdlib_dir = joinpath(exec_prefix, PLATSTDLIB_LANDMARK)
|
|
||||||
else:
|
|
||||||
platstdlib_dir = ''
|
|
||||||
|
|
||||||
|
|
||||||
# For a venv, update the main prefix/exec_prefix but leave the base ones unchanged
|
# For a venv, update the main prefix/exec_prefix but leave the base ones unchanged
|
||||||
# XXX: We currently do not update prefix here, but it happens in site.py
|
# XXX: We currently do not update prefix here, but it happens in site.py
|
||||||
#if venv_prefix:
|
#if venv_prefix:
|
||||||
|
@ -706,8 +692,9 @@ elif not pythonpath_was_set:
|
||||||
pythonpath.extend(v.split(DELIM))
|
pythonpath.extend(v.split(DELIM))
|
||||||
i += 1
|
i += 1
|
||||||
# Paths from the core key get appended last, but only
|
# Paths from the core key get appended last, but only
|
||||||
# when home was not set and we aren't in a build dir
|
# when home was not set and we haven't found our stdlib
|
||||||
if not home_was_set and not venv_prefix and not build_prefix:
|
# some other way.
|
||||||
|
if not home and not stdlib_dir:
|
||||||
v = winreg.QueryValue(key, None)
|
v = winreg.QueryValue(key, None)
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
pythonpath.extend(v.split(DELIM))
|
pythonpath.extend(v.split(DELIM))
|
||||||
|
@ -722,6 +709,11 @@ elif not pythonpath_was_set:
|
||||||
pythonpath.append(joinpath(prefix, p))
|
pythonpath.append(joinpath(prefix, p))
|
||||||
|
|
||||||
# Then add stdlib_dir and platstdlib_dir
|
# Then add stdlib_dir and platstdlib_dir
|
||||||
|
if not stdlib_dir and prefix:
|
||||||
|
stdlib_dir = joinpath(prefix, STDLIB_SUBDIR)
|
||||||
|
if not platstdlib_dir and exec_prefix:
|
||||||
|
platstdlib_dir = joinpath(exec_prefix, PLATSTDLIB_LANDMARK)
|
||||||
|
|
||||||
if os_name == 'nt':
|
if os_name == 'nt':
|
||||||
# QUIRK: Windows generates paths differently
|
# QUIRK: Windows generates paths differently
|
||||||
if platstdlib_dir:
|
if platstdlib_dir:
|
||||||
|
@ -792,5 +784,6 @@ config['base_prefix'] = base_prefix or prefix
|
||||||
config['base_exec_prefix'] = base_exec_prefix or exec_prefix
|
config['base_exec_prefix'] = base_exec_prefix or exec_prefix
|
||||||
|
|
||||||
config['platlibdir'] = platlibdir
|
config['platlibdir'] = platlibdir
|
||||||
config['stdlib_dir'] = stdlib_dir
|
# test_embed expects empty strings, not None
|
||||||
config['platstdlib_dir'] = platstdlib_dir
|
config['stdlib_dir'] = stdlib_dir or ''
|
||||||
|
config['platstdlib_dir'] = platstdlib_dir or ''
|
||||||
|
|
Loading…
Reference in New Issue