Skip to content

Commit f8c93d4

Browse files
authored
gh-155254: Avoid warning about missing stdlib when using _pth files (GH-156015)
1 parent 67f4d53 commit f8c93d4

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

Doc/library/sys_path_init.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ Please refer to :mod:`site`'s
105105
mechanism, such as :mod:`venv`, that many virtual environment implementations
106106
follow.
107107

108+
.. _sys-path-init-_pth-files:
109+
108110
_pth files
109111
----------
110112

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid warning about missing standard library when using :ref:`sys-path-init-_pth-files`.

Modules/getpath.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -766,10 +766,10 @@ def search_up(prefix, *landmarks, test=isfile):
766766
# SANITY CHECKS
767767
# ******************************************************************************
768768

769-
# Warn if the standard library is missing, unless pythonpath_was_set was set, as
770-
# that skips parts of the stdlib directories calculation — assume the provided
771-
# pythonpath is correct. This is how subinterpreters initialize the path for eg.
772-
if not py_setpath and not pythonpath_was_set:
769+
# Warn if we did a search for the standard library and couldn't find it. Never
770+
# show a warning if paths were provided explicitly, since we trust the caller
771+
# knows what they're doing even if the layout doesn't look "normal".
772+
if not (py_setpath or pythonpath_was_set or pth):
773773
home_hint = f"The Python 'home' directory was set to {home!r}, is this correct?"
774774
if (not stdlib_zip or not isfile(stdlib_zip)) and (not stdlib_dir or not isdir(stdlib_dir)):
775775
hint = home_hint if home else f'sys.prefix is set to {prefix}, is this correct?'

0 commit comments

Comments
 (0)