Skip to content

Commit b4a9069

Browse files
!drop revert fixes to test we catch regression
Revert commits: * 7015485. * 2950bc5.
1 parent ed9aceb commit b4a9069

File tree

6 files changed

+23
-82
lines changed

6 files changed

+23
-82
lines changed

.github/workflows/jit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
110110
# The `find` line is required as a result of https://github.com/actions/runner-images/issues/9966.
111111
# This is a bug in the macOS runner image where the pre-installed Python is installed in the same
112-
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
112+
# directory as the Homebrew Python, which causes the build to fail for macos-13. This line removes
113113
# the symlink to the pre-installed Python so that the Homebrew Python is used instead.
114114
- name: Native macOS
115115
if: runner.os == 'macOS'

Lib/sysconfig/__init__.py

Lines changed: 16 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ def joinuser(*args):
173173
_PY_VERSION = sys.version.split()[0]
174174
_PY_VERSION_SHORT = f'{sys.version_info[0]}.{sys.version_info[1]}'
175175
_PY_VERSION_SHORT_NO_DOT = f'{sys.version_info[0]}{sys.version_info[1]}'
176+
_PREFIX = os.path.normpath(sys.prefix)
176177
_BASE_PREFIX = os.path.normpath(sys.base_prefix)
178+
_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
177179
_BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
178180
# Mutex guarding initialization of _CONFIG_VARS.
179181
_CONFIG_VARS_LOCK = threading.RLock()
@@ -316,22 +318,14 @@ def get_default_scheme():
316318

317319
def get_makefile_filename():
318320
"""Return the path of the Makefile."""
319-
320-
# GH-127429: When cross-compiling, use the Makefile from the target, instead of the host Python.
321-
if cross_base := os.environ.get('_PYTHON_PROJECT_BASE'):
322-
return os.path.join(cross_base, 'Makefile')
323-
324321
if _PYTHON_BUILD:
325322
return os.path.join(_PROJECT_BASE, "Makefile")
326-
327323
if hasattr(sys, 'abiflags'):
328324
config_dir_name = f'config-{_PY_VERSION_SHORT}{sys.abiflags}'
329325
else:
330326
config_dir_name = 'config'
331-
332327
if hasattr(sys.implementation, '_multiarch'):
333328
config_dir_name += f'-{sys.implementation._multiarch}'
334-
335329
return os.path.join(get_path('stdlib'), config_dir_name, 'Makefile')
336330

337331

@@ -470,44 +464,27 @@ def get_path(name, scheme=get_default_scheme(), vars=None, expand=True):
470464
def _init_config_vars():
471465
global _CONFIG_VARS
472466
_CONFIG_VARS = {}
473-
474-
prefix = os.path.normpath(sys.prefix)
475-
exec_prefix = os.path.normpath(sys.exec_prefix)
476-
base_prefix = _BASE_PREFIX
477-
base_exec_prefix = _BASE_EXEC_PREFIX
478-
479-
try:
480-
abiflags = sys.abiflags
481-
except AttributeError:
482-
abiflags = ''
483-
484-
if os.name == 'posix':
485-
_init_posix(_CONFIG_VARS)
486-
# If we are cross-compiling, load the prefixes from the Makefile instead.
487-
if '_PYTHON_PROJECT_BASE' in os.environ:
488-
prefix = _CONFIG_VARS['prefix']
489-
exec_prefix = _CONFIG_VARS['exec_prefix']
490-
base_prefix = _CONFIG_VARS['prefix']
491-
base_exec_prefix = _CONFIG_VARS['exec_prefix']
492-
abiflags = _CONFIG_VARS['ABIFLAGS']
493-
494467
# Normalized versions of prefix and exec_prefix are handy to have;
495468
# in fact, these are the standard versions used most places in the
496469
# Distutils.
497-
_CONFIG_VARS['prefix'] = prefix
498-
_CONFIG_VARS['exec_prefix'] = exec_prefix
470+
_CONFIG_VARS['prefix'] = _PREFIX
471+
_CONFIG_VARS['exec_prefix'] = _EXEC_PREFIX
499472
_CONFIG_VARS['py_version'] = _PY_VERSION
500473
_CONFIG_VARS['py_version_short'] = _PY_VERSION_SHORT
501474
_CONFIG_VARS['py_version_nodot'] = _PY_VERSION_SHORT_NO_DOT
502-
_CONFIG_VARS['installed_base'] = base_prefix
503-
_CONFIG_VARS['base'] = prefix
504-
_CONFIG_VARS['installed_platbase'] = base_exec_prefix
505-
_CONFIG_VARS['platbase'] = exec_prefix
475+
_CONFIG_VARS['installed_base'] = _BASE_PREFIX
476+
_CONFIG_VARS['base'] = _PREFIX
477+
_CONFIG_VARS['installed_platbase'] = _BASE_EXEC_PREFIX
478+
_CONFIG_VARS['platbase'] = _EXEC_PREFIX
506479
_CONFIG_VARS['projectbase'] = _PROJECT_BASE
507480
_CONFIG_VARS['platlibdir'] = sys.platlibdir
508481
_CONFIG_VARS['implementation'] = _get_implementation()
509482
_CONFIG_VARS['implementation_lower'] = _get_implementation().lower()
510-
_CONFIG_VARS['abiflags'] = abiflags
483+
try:
484+
_CONFIG_VARS['abiflags'] = sys.abiflags
485+
except AttributeError:
486+
# sys.abiflags may not be defined on all platforms.
487+
_CONFIG_VARS['abiflags'] = ''
511488
try:
512489
_CONFIG_VARS['py_version_nodot_plat'] = sys.winver.replace('.', '')
513490
except AttributeError:
@@ -516,6 +493,8 @@ def _init_config_vars():
516493
if os.name == 'nt':
517494
_init_non_posix(_CONFIG_VARS)
518495
_CONFIG_VARS['VPATH'] = sys._vpath
496+
if os.name == 'posix':
497+
_init_posix(_CONFIG_VARS)
519498
if _HAS_USER_BASE:
520499
# Setting 'userbase' is done below the call to the
521500
# init function to enable using 'get_config_var' in
@@ -562,19 +541,9 @@ def get_config_vars(*args):
562541
With arguments, return a list of values that result from looking up
563542
each argument in the configuration variable dictionary.
564543
"""
565-
global _CONFIG_VARS_INITIALIZED
566544

567545
# Avoid claiming the lock once initialization is complete.
568-
if _CONFIG_VARS_INITIALIZED:
569-
# GH-126789: If sys.prefix or sys.exec_prefix were updated, invalidate the cache.
570-
prefix = os.path.normpath(sys.prefix)
571-
exec_prefix = os.path.normpath(sys.exec_prefix)
572-
if _CONFIG_VARS['prefix'] != prefix or _CONFIG_VARS['exec_prefix'] != exec_prefix:
573-
with _CONFIG_VARS_LOCK:
574-
_CONFIG_VARS_INITIALIZED = False
575-
_init_config_vars()
576-
else:
577-
# Initialize the config_vars cache.
546+
if not _CONFIG_VARS_INITIALIZED:
578547
with _CONFIG_VARS_LOCK:
579548
# Test again with the lock held to avoid races. Note that
580549
# we test _CONFIG_VARS here, not _CONFIG_VARS_INITIALIZED,

Lib/sysconfig/__main__.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
_PYTHON_BUILD,
88
_get_sysconfigdata_name,
99
get_config_h_filename,
10-
get_config_var,
1110
get_config_vars,
1211
get_default_scheme,
1312
get_makefile_filename,
@@ -162,7 +161,7 @@ def _print_config_dict(d, stream):
162161

163162
def _get_pybuilddir():
164163
pybuilddir = f'build/lib.{get_platform()}-{get_python_version()}'
165-
if get_config_var('Py_DEBUG') == '1':
164+
if hasattr(sys, "gettotalrefcount"):
166165
pybuilddir += '-pydebug'
167166
return pybuilddir
168167

@@ -230,15 +229,11 @@ def _generate_posix_vars():
230229
f.write('build_time_vars = ')
231230
_print_config_dict(vars, stream=f)
232231

233-
print(f'Written {destfile}')
234-
235232
# Write a JSON file with the output of sysconfig.get_config_vars
236233
jsonfile = os.path.join(pybuilddir, _get_json_data_name())
237234
with open(jsonfile, 'w') as f:
238235
json.dump(get_config_vars(), f, indent=2)
239236

240-
print(f'Written {jsonfile}')
241-
242237
# Create file used for sys.path fixup -- see Modules/getpath.c
243238
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
244239
f.write(pybuilddir)

Lib/test/test_sysconfig.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def setUp(self):
5353
os.uname = self._get_uname
5454
# saving the environment
5555
self.name = os.name
56-
self.prefix = sys.prefix
57-
self.exec_prefix = sys.exec_prefix
5856
self.platform = sys.platform
5957
self.version = sys.version
6058
self._framework = sys._framework
@@ -79,8 +77,6 @@ def tearDown(self):
7977
else:
8078
del os.uname
8179
os.name = self.name
82-
sys.prefix = self.prefix
83-
sys.exec_prefix = self.exec_prefix
8480
sys.platform = self.platform
8581
sys.version = self.version
8682
sys._framework = self._framework
@@ -657,27 +653,6 @@ def test_sysconfigdata_json(self):
657653

658654
self.assertEqual(system_config_vars, json_config_vars)
659655

660-
def test_sysconfig_config_vars_no_prefix_cache(self):
661-
sys.prefix = 'prefix-AAA'
662-
sys.exec_prefix = 'exec-prefix-AAA'
663-
664-
config_vars = sysconfig.get_config_vars()
665-
666-
self.assertEqual(config_vars['prefix'], sys.prefix)
667-
self.assertEqual(config_vars['base'], sys.prefix)
668-
self.assertEqual(config_vars['exec_prefix'], sys.exec_prefix)
669-
self.assertEqual(config_vars['platbase'], sys.exec_prefix)
670-
671-
sys.prefix = 'prefix-BBB'
672-
sys.exec_prefix = 'exec-prefix-BBB'
673-
674-
config_vars = sysconfig.get_config_vars()
675-
676-
self.assertEqual(config_vars['prefix'], sys.prefix)
677-
self.assertEqual(config_vars['base'], sys.prefix)
678-
self.assertEqual(config_vars['exec_prefix'], sys.exec_prefix)
679-
self.assertEqual(config_vars['platbase'], sys.exec_prefix)
680-
681656

682657
class MakefileTests(unittest.TestCase):
683658

configure

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1612,8 +1612,8 @@ if test "$cross_compiling" = yes; then
16121612
RUNSHARED=
16131613
fi
16141614

1615-
# HOSTRUNNER - Program to run CPython for the host platform
16161615
AC_MSG_CHECKING([HOSTRUNNER])
1616+
AC_ARG_VAR([HOSTRUNNER], [Program to run CPython for the host platform])
16171617
if test -z "$HOSTRUNNER"
16181618
then
16191619
AS_CASE([$ac_sys_system],

0 commit comments

Comments
 (0)