10000 gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation by neonene · Pull Request #93641 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-91985: Ensure in-tree builds override platstdlib_dir in every path calculation #93641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test, etc.
  • Loading branch information
neonene committed Jun 11, 2022
commit 0be59f2ab5cefc81e50aee4104d3bb9ccdd0aad4
37 changes: 37 additions & 0 deletions Lib/test/test_getpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,43 @@ def test_buildtree_pythonhome_win32(self):
actual = getpath(ns, expected)
self.assertEqual(expected, actual)

def test_run_in_tree_build_win32(self):
"Test _is_python_build fields with edge cases.(gh-91985)"
def read_pathconfig(config, attr):
if _Py_path_config[attr] >= 0 and config[attr] <= 0:
config[attr] = _Py_path_config[attr]

def update_pathconfig(config, attr):
if config[attr] > 0:
_Py_path_config[attr] = config[attr]

edges = {
( 0, -1) : 0,
(-1, 0) : -1,
(-1, -1) : -1,
( 1, 0) : 1,
}
for key in edges:
_Py_path_config = dict(
_is_python_build=key[0],
)
ns = MockNTNamespace(
argv0=r"C:\CPython\PCbuild\amd64\python.exe",
)
ns['config'].update(
_is_python_build=key[1],
)
# _PyConfig_InitPathConfig emulation
read_pathconfig(ns['config'], '_is_python_build')
expected = dict(
_is_python_build=ns['config']['_is_python_build'],
build_prefix=None, # no build-landmark
)
actual = getpath(ns, expected)
self.assertEqual(actual, expected)
update_pathconfig(actual, '_is_python_build')
self.assertEqual(_Py_path_config['_is_python_build'], edges[key])

def test_normal_posix(self):
"Test a 'standard' install layout on *nix"
ns = MockPosixNamespace(
Expand Down
2 changes: 1 addition & 1 deletion Modules/getpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def search_up(prefix, *landmarks, test=isfile):
build_prefix = None

if ((not home_was_set and real_executable_dir and not py_setpath)
or config.get('_is_python_build')):
or config.get('_is_python_build', 0) > 0):
# Detect a build marker and use it to infer prefix, exec_prefix,
# stdlib_dir and the platstdlib_dir directories.
try:
Expand Down
2 changes: 1 addition & 1 deletion Python/pathconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ _PyPathConfig_ReadGlobal(PyConfig *config)

#define COPY_INT(ATTR) \
do { \
if ((_Py_path_config.ATTR > 0) && (config->ATTR <= 0)) { \
if ((_Py_path_config.ATTR >= 0) && (config->ATTR <= 0)) { \
config->ATTR = _Py_path_config.ATTR; \
} \
} while (0)
Expand Down
0