Skip to content

Commit 080a70a

Browse files
committed
gh-98718: re-use already calculated is_python_build from getpath
1 parent de69816 commit 080a70a

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

Lib/sysconfig.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,9 @@ def is_python_build(check_home=None):
221221
import warnings
222222
warnings.warn("check_home argument is deprecated and ignored.",
223223
DeprecationWarning, stacklevel=2)
224-
for fn in ("Setup", "Setup.local"):
225-
if os.path.isfile(os.path.join(_PROJECT_BASE, "Modules", fn)):
226-
return True
227-
return False
224+
return sys._is_python_build
228225

229-
_PYTHON_BUILD = is_python_build()
226+
_PYTHON_BUILD = sys._is_python_build
230227

231228
if _PYTHON_BUILD:
232229
for scheme in ('posix_prefix', 'posix_home'):

Python/sysmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,6 +3304,9 @@ _PySys_UpdateConfig(PyThreadState *tstate)
33043304
SET_SYS_FROM_WSTR(SYS_ATTR, WSTR); \
33053305
}
33063306

3307+
#define COPY_BOOL(KEY, VALUE) \
3308+
SET_SYS(KEY, PyBool_FromLong(VALUE));
3309+
33073310
if (config->module_search_paths_set) {
33083311
COPY_LIST("path", config->module_search_paths);
33093312
}
@@ -3315,6 +3318,7 @@ _PySys_UpdateConfig(PyThreadState *tstate)
33153318
COPY_WSTR("exec_prefix", config->exec_prefix);
33163319
COPY_WSTR("base_exec_prefix", config->base_exec_prefix);
33173320
COPY_WSTR("platlibdir", config->platlibdir);
3321+
COPY_BOOL("_is_python_build", config->_is_python_build);
33183322

33193323
if (config->pycache_prefix != NULL) {
33203324
SET_SYS_FROM_WSTR("pycache_prefix", config->pycache_prefix);

0 commit comments

Comments
 (0)