Skip to content

Commit b025bd4

Browse files
authored
Merge branch 'main' into arm-runners
2 parents c5dc6b0 + 3a77980 commit b025bd4

File tree

5 files changed

+69
-38
lines changed

5 files changed

+69
-38
lines changed

.github/workflows/jit.yml

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ jobs:
5454
- x86_64-apple-darwin/clang
5555
- aarch64-apple-darwin/clang
5656
- x86_64-unknown-linux-gnu/gcc
57-
- x86_64-unknown-linux-gnu/clang
5857
- aarch64-unknown-linux-gnu/gcc
59-
- aarch64-unknown-linux-gnu/clang
6058
debug:
6159
- true
6260
- false
@@ -68,46 +66,27 @@ jobs:
6866
- target: i686-pc-windows-msvc/msvc
6967
architecture: Win32
7068
runner: windows-latest
71-
compiler: msvc
7269
- target: x86_64-pc-windows-msvc/msvc
7370
architecture: x64
7471
runner: windows-latest
75-
compiler: msvc
7672
- target: aarch64-pc-windows-msvc/msvc
7773
architecture: ARM64
7874
runner: windows-latest
79-
compiler: msvc
8075
- target: x86_64-apple-darwin/clang
8176
architecture: x86_64
8277
runner: macos-13
83-
compiler: clang
8478
- target: aarch64-apple-darwin/clang
8579
architecture: aarch64
8680
runner: macos-14
87-
compiler: clang
8881
- target: x86_64-unknown-linux-gnu/gcc
8982
architecture: x86_64
9083
runner: ubuntu-24.04
91-
compiler: gcc
92-
- target: x86_64-unknown-linux-gnu/clang
93-
architecture: x86_64
94-
runner: ubuntu-24.04
95-
compiler: clang
9684
- target: aarch64-unknown-linux-gnu/gcc
9785
architecture: aarch64
9886
runner: ubuntu-24.04-aarch64
99-
compiler: gcc
100-
- target: aarch64-unknown-linux-gnu/clang
101-
architecture: aarch64
102-
runner: ubuntu-24.04-aarch64
103-
compiler: clang
10487
exclude:
10588
- target: aarch64-unknown-linux-gnu/gcc
10689
is-fork: true
107-
- target: aarch64-unknown-linux-gnu/clang
108-
is-fork: true
109-
env:
110-
CC: ${{ matrix.compiler }}
11190
steps:
11291
- uses: actions/checkout@v4
11392
- uses: actions/setup-python@v5
@@ -118,10 +97,10 @@ jobs:
11897
if: runner.os == 'Windows' && matrix.architecture != 'ARM64'
11998
run: |
12099
choco install llvm --allow-downgrade --no-progress --version ${{ matrix.llvm }}.1.0
121-
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '--pgo' }} -p ${{ matrix.architecture }}
100+
./PCbuild/build.bat --experimental-jit ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }}
122101
./PCbuild/rt.bat ${{ matrix.debug && '-d' || '' }} -p ${{ matrix.architecture }} -q --multiprocess 0 --timeout 4500 --verbose2 --verbose3
123102
124-
# No PGO or tests (yet):
103+
# No tests (yet):
125104
- name: Emulated Windows
126105
if: runner.os == 'Windows' && matrix.architecture == 'ARM64'
127106
run: |
@@ -139,7 +118,7 @@ jobs:
139118
find /usr/local/bin -lname '*/Library/Frameworks/Python.framework/*' -delete
140119
brew install llvm@${{ matrix.llvm }}
141120
export SDKROOT="$(xcrun --show-sdk-path)"
142-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
121+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
143122
make all --jobs 4
144123
./python.exe -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
145124
@@ -148,7 +127,7 @@ jobs:
148127
run: |
149128
sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ matrix.llvm }}
150129
export PATH="$(llvm-config-${{ matrix.llvm }} --bindir):$PATH"
151-
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '--enable-optimizations --with-lto' }}
130+
./configure --enable-experimental-jit ${{ matrix.debug && '--with-pydebug' || '' }}
152131
make all --jobs 4
153132
./python -m test --multiprocess 0 --timeout 4500 --verbose2 --verbose3
154133

Lib/sysconfig/__main__.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import json
12
import os
23
import sys
4+
import types
35
from sysconfig import (
46
_ALWAYS_STR,
57
_PYTHON_BUILD,
@@ -157,6 +159,19 @@ def _print_config_dict(d, stream):
157159
print ("}", file=stream)
158160

159161

162+
def _get_pybuilddir():
163+
pybuilddir = f'build/lib.{get_platform()}-{get_python_version()}'
164+
if hasattr(sys, "gettotalrefcount"):
165+
pybuilddir += '-pydebug'
166+
return pybuilddir
167+
168+
169+
def _get_json_data_name():
170+
name = _get_sysconfigdata_name()
171+
assert name.startswith('_sysconfigdata')
172+
return name.replace('_sysconfigdata', '_sysconfig_vars') + '.json'
173+
174+
160175
def _generate_posix_vars():
161176
"""Generate the Python module containing build-time variables."""
162177
vars = {}
@@ -185,6 +200,8 @@ def _generate_posix_vars():
185200
if _PYTHON_BUILD:
186201
vars['BLDSHARED'] = vars['LDSHARED']
187202

203+
name = _get_sysconfigdata_name()
204+
188205
# There's a chicken-and-egg situation on OS X with regards to the
189206
# _sysconfigdata module after the changes introduced by #15298:
190207
# get_config_vars() is called by get_platform() as part of the
@@ -196,16 +213,13 @@ def _generate_posix_vars():
196213
# _sysconfigdata module manually and populate it with the build vars.
197214
# This is more than sufficient for ensuring the subsequent call to
198215
# get_platform() succeeds.
199-
name = _get_sysconfigdata_name()
200-
if 'darwin' in sys.platform:
201-
import types
202-
module = types.ModuleType(name)
203-
module.build_time_vars = vars
204-
sys.modules[name] = module
216+
# GH-127178: Since we started generating a .json file, we also need this to
217+
# be able to run sysconfig.get_config_vars().
218+
module = types.ModuleType(name)
219+
module.build_time_vars = vars
220+
sys.modules[name] = module
205221

206-
pybuilddir = f'build/lib.{get_platform()}-{get_python_version()}'
207-
if hasattr(sys, "gettotalrefcount"):
208-
pybuilddir += '-pydebug'
222+
pybuilddir = _get_pybuilddir()
209223
os.makedirs(pybuilddir, exist_ok=True)
210224
destfile = os.path.join(pybuilddir, name + '.py')
211225

@@ -215,6 +229,11 @@ def _generate_posix_vars():
215229
f.write('build_time_vars = ')
216230
_print_config_dict(vars, stream=f)
217231

232+
# Write a JSON file with the output of sysconfig.get_config_vars
233+
jsonfile = os.path.join(pybuilddir, _get_json_data_name())
234+
with open(jsonfile, 'w') as f:
235+
json.dump(get_config_vars(), f, indent=2)
236+
218237
# Create file used for sys.path fixup -- see Modules/getpath.c
219238
with open('pybuilddir.txt', 'w', encoding='utf8') as f:
220239
f.write(pybuilddir)

Lib/test/test_sysconfig.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from test.support import (
1313
captured_stdout,
14+
is_android,
1415
is_apple_mobile,
1516
is_wasi,
1617
PythonSymlink,
@@ -25,8 +26,9 @@
2526
from sysconfig import (get_paths, get_platform, get_config_vars,
2627
get_path, get_path_names, _INSTALL_SCHEMES,
2728
get_default_scheme, get_scheme_names, get_config_var,
28-
_expand_vars, _get_preferred_schemes)
29-
from sysconfig.__main__ import _main, _parse_makefile
29+
_expand_vars, _get_preferred_schemes,
30+
is_python_build, _PROJECT_BASE)
31+
from sysconfig.__main__ import _main, _parse_makefile, _get_pybuilddir, _get_json_data_name
3032
import _imp
3133
import _osx_support
3234
import _sysconfig
@@ -39,6 +41,7 @@ class TestSysConfig(unittest.TestCase):
3941

4042
def setUp(self):
4143
super(TestSysConfig, self).setUp()
44+
self.maxDiff = None
4245
self.sys_path = sys.path[:]
4346
# patching os.uname
4447
if hasattr(os, 'uname'):
@@ -625,6 +628,32 @@ def test_makefile_overwrites_config_vars(self):
625628
self.assertNotEqual(data['prefix'], data['base_prefix'])
626629
self.assertNotEqual(data['exec_prefix'], data['base_exec_prefix'])
627630

631+
@unittest.skipIf(os.name != 'posix', '_sysconfig-vars JSON file is only available on POSIX')
632+
@unittest.skipIf(is_wasi, "_sysconfig-vars JSON file currently isn't available on WASI")
633+
@unittest.skipIf(is_android or is_apple_mobile, 'Android and iOS change the prefix')
634+
def test_sysconfigdata_json(self):
635+
if '_PYTHON_SYSCONFIGDATA_PATH' in os.environ:
636+
data_dir = os.environ['_PYTHON_SYSCONFIGDATA_PATH']
637+
elif is_python_build():
638+
data_dir = os.path.join(_PROJECT_BASE, _get_pybuilddir())
639+
else:
640+
data_dir = sys._stdlib_dir
641+
642+
json_data_path = os.path.join(data_dir, _get_json_data_name())
643+
644+
with open(json_data_path) as f:
645+
json_config_vars = json.load(f)
646+
647+
system_config_vars = get_config_vars()
648+
649+
# Ignore keys in the check
650+
for key in ('projectbase', 'srcdir'):
651+
json_config_vars.pop(key)
652+
system_config_vars.pop(key)
653+
654+
self.assertEqual(system_config_vars, json_config_vars)
655+
656+
628657
class MakefileTests(unittest.TestCase):
629658

630659
@unittest.skipIf(sys.platform.startswith('win'),

Makefile.pre.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,8 +2645,8 @@ libinstall: all $(srcdir)/Modules/xxmodule.c
26452645
esac; \
26462646
done; \
26472647
done
2648-
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py \
2649-
$(DESTDIR)$(LIBDEST); \
2648+
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).py $(DESTDIR)$(LIBDEST); \
2649+
$(INSTALL_DATA) `cat pybuilddir.txt`/_sysconfig_vars_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH).json $(DESTDIR)$(LIBDEST); \
26502650
$(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
26512651
@ # If app store compliance has been configured, apply the patch to the
26522652
@ # installed library code. The patch has been previously validated against
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
A ``_sysconfig_vars_(...).json`` file is now shipped in the standard library
2+
directory. It contains the output of :func:`sysconfig.get_config_vars` on
3+
the default environment encoded as JSON data. This is an implementation
4+
detail, and may change at any time.

0 commit comments

Comments
 (0)