Skip to content

Commit d6133f2

Browse files
Merge branch 'main' into startcontinueid
2 parents 4900fb7 + 25bd72d commit d6133f2

File tree

247 files changed

+4213
-1647
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

247 files changed

+4213
-1647
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"image": "ghcr.io/python/wasicontainer:latest",
3+
"onCreateCommand": [
4+
// Install common tooling.
5+
"dnf",
6+
"install",
7+
"-y",
8+
// For umask fix below.
9+
"/usr/bin/setfacl"
10+
],
11+
"updateContentCommand": {
12+
// Using the shell for `nproc` usage.
13+
"python": "python3 Tools/wasm/wasi build --quiet -- --with-pydebug -C"
14+
},
15+
"postCreateCommand": {
16+
// https://github.com/orgs/community/discussions/26026
17+
"umask fix: workspace": ["sudo", "setfacl", "-bnR", "."],
18+
"umask fix: /tmp": ["sudo", "setfacl", "-bnR", "/tmp"]
19+
},
20+
"customizations": {
21+
"vscode": {
22+
"extensions": [
23+
// Highlighting for Parser/Python.asdl.
24+
"brettcannon.zephyr-asdl",
25+
// Highlighting for configure.ac.
26+
"maelvalais.autoconf",
27+
// C auto-complete.
28+
"ms-vscode.cpptools",
29+
// Python auto-complete.
30+
"ms-python.python"
31+
],
32+
"settings": {
33+
"C_Cpp.default.compilerPath": "/usr/bin/clang",
34+
"C_Cpp.default.cStandard": "c11",
35+
"C_Cpp.default.defines": [
36+
"CONFIG_64",
37+
"Py_BUILD_CORE"
38+
],
39+
"C_Cpp.default.includePath": [
40+
"${workspaceFolder}/*",
41+
"${workspaceFolder}/Include/**"
42+
],
43+
// https://github.com/microsoft/vscode-cpptools/issues/10732
44+
"C_Cpp.errorSquiggles": "disabled",
45+
"editor.insertSpaces": true,
46+
"editor.rulers": [
47+
80
48+
],
49+
"editor.tabSize": 4,
50+
"editor.trimAutoWhitespace": true,
51+
"files.associations": {
52+
"*.h": "c"
53+
},
54+
"files.encoding": "utf8",
55+
"files.eol": "\n",
56+
"files.insertFinalNewline": true,
57+
"files.trimTrailingWhitespace": true,
58+
"python.analysis.diagnosticSeverityOverrides": {
59+
// Complains about shadowing the stdlib w/ the stdlib.
60+
"reportShadowedImports": "none",
61+
// Doesn't like _frozen_importlib.
62+
"reportMissingImports": "none"
63+
},
64+
"python.analysis.extraPaths": [
65+
"Lib"
66+
],
67+
"[restructuredtext]": {
68+
"editor.tabSize": 3
69+
}
70+
}
71+
}
72+
}
73+
}

.github/workflows/build.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,29 @@ jobs:
414414
- name: Build and test
415415
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android
416416

417+
build-ios:
418+
name: iOS
419+
needs: build-context
420+
if: needs.build-context.outputs.run-tests == 'true'
421+
timeout-minutes: 60
422+
runs-on: macos-15
423+
steps:
424+
- uses: actions/checkout@v4
425+
with:
426+
persist-credentials: false
427+
428+
# GitHub recommends explicitly selecting the desired Xcode version:
429+
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
430+
# This became a necessity as a result of
431+
# https://github.com/actions/runner-images/issues/12541 and
432+
# https://github.com/actions/runner-images/issues/12751.
433+
- name: Select Xcode version
434+
run: |
435+
sudo xcode-select --switch /Applications/Xcode_16.4.app
436+
437+
- name: Build and test
438+
run: python3 Apple ci iOS --fast-ci --simulator 'iPhone 16e,OS=18.5'
439+
417440
build-wasi:
418441
name: 'WASI'
419442
needs: build-context
@@ -723,6 +746,7 @@ jobs:
723746
- build-ubuntu-ssltests-awslc
724747
- build-ubuntu-ssltests-openssl
725748
- build-android
749+
- build-ios
726750
- build-wasi
727751
- test-hypothesis
728752
- build-asan
@@ -759,6 +783,7 @@ jobs:
759783
build-ubuntu-ssltests-awslc,
760784
build-ubuntu-ssltests-openssl,
761785
build-android,
786+
build-ios,
762787
build-wasi,
763788
test-hypothesis,
764789
build-asan,

.github/workflows/reusable-wasi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
runs-on: ubuntu-24.04
1717
timeout-minutes: 60
1818
env:
19-
WASMTIME_VERSION: 22.0.0
20-
WASI_SDK_VERSION: 24
19+
WASMTIME_VERSION: 38.0.2
20+
WASI_SDK_VERSION: 25
2121
WASI_SDK_PATH: /opt/wasi-sdk
2222
CROSS_BUILD_PYTHON: cross-build/build
2323
CROSS_BUILD_WASI: cross-build/wasm32-wasip1

Apple/__main__.py

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
823823
+ [
824824
"--",
825825
"test",
826-
"--slow-ci" if context.slow else "--fast-ci",
826+
f"--{context.ci_mode}-ci",
827827
"--single-process",
828828
"--no-randomize",
829829
# Timeout handling requires subprocesses; explicitly setting
@@ -836,11 +836,39 @@ def test(context: argparse.Namespace, host: str | None = None) -> None:
836836
)
837837

838838

839+
def apple_sim_host(platform_name: str) -> str:
840+
"""Determine the native simulator target for this platform."""
841+
for _, slice_parts in HOSTS[platform_name].items():
842+
for host_triple in slice_parts:
843+
parts = host_triple.split('-')
844+
if parts[0] == platform.machine() and parts[-1] == "simulator":
845+
return host_triple
846+
847+
raise KeyError(platform_name)
848+
849+
839850
def ci(context: argparse.Namespace) -> None:
840-
"""The implementation of the "ci" command."""
851+
"""The implementation of the "ci" command.
852+
853+
In "Fast" mode, this compiles the build python, and the simulator for the
854+
build machine's architecture; and runs the test suite with `--fast-ci`
855+
configuration.
856+
857+
In "Slow" mode, it compiles the build python, plus all candidate
858+
architectures (both device and simulator); then runs the test suite with
859+
`--slow-ci` configuration.
860+
"""
841861
clean(context, "all")
842-
build(context, host="all")
843-
test(context, host="all")
862+
if context.ci_mode == "slow":
863+
# In slow mode, build and test the full XCframework
864+
build(context, host="all")
865+
test(context, host="all")
866+
else:
867+
# In fast mode, just build the simulator platform.
868+
sim_host = apple_sim_host(context.platform)
869+
build(context, host="build")
870+
build(context, host=sim_host)
871+
test(context, host=sim_host)
844872

845873

846874
def parse_args() -> argparse.Namespace:
@@ -947,11 +975,13 @@ def parse_args() -> argparse.Namespace:
947975
"an ARM64 iPhone 16 Pro simulator running iOS 26.0."
948976
),
949977
)
950-
cmd.add_argument(
951-
"--slow",
952-
action="store_true",
953-
help="Run tests with --slow-ci options.",
954-
)
978+
group = cmd.add_mutually_exclusive_group()
979+
group.add_argument(
980+
"--fast-ci", action="store_const", dest="ci_mode", const="fast",
981+
help="Add test arguments for GitHub Actions")
982+
group.add_argument(
983+
"--slow-ci", action="store_const", dest="ci_mode", const="slow",
984+
help="Add test arguments for buildbots")
955985

956986
for subcommand in [configure_build, configure_host, build, ci]:
957987
subcommand.add_argument(
@@ -1012,4 +1042,10 @@ def signal_handler(*args):
10121042

10131043

10141044
if __name__ == "__main__":
1045+
# Under the buildbot, stdout is not a TTY, but we must still flush after
1046+
# every line to make sure our output appears in the correct order relative
1047+
# to the output of our subprocesses.
1048+
for stream in [sys.stdout, sys.stderr]:
1049+
stream.reconfigure(line_buffering=True)
1050+
10151051
main()

Apple/iOS/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,17 @@ Once you have a built an XCframework, you can test that framework by running:
224224

225225
$ python Apple test iOS
226226

227+
This test will attempt to find an "SE-class" simulator (i.e., an iPhone SE, or
228+
iPhone 16e, or similar), and run the test suite on the most recent version of
229+
iOS that is available. You can specify a simulator using the `--simulator`
230+
command line argument, providing the name of the simulator (e.g., `--simulator
231+
'iPhone 16 Pro'`). You can also use this argument to control the OS version used
232+
for testing; `--simulator 'iPhone 16 Pro,OS=18.2'` would attempt to run the
233+
tests on an iPhone 16 Pro running iOS 18.2.
234+
235+
If the test runner is executed on GitHub Actions, the `GITHUB_ACTIONS`
236+
environment variable will be exposed to the iOS process at runtime.
237+
227238
### Testing a single-architecture framework
228239

229240
The `Apple/testbed` folder that contains an Xcode project that is able to run

Apple/testbed/TestbedTests/TestbedTests.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ - (void)testPython {
3535
setenv("NO_COLOR", "1", true);
3636
setenv("PYTHON_COLORS", "0", true);
3737

38+
if (getenv("GITHUB_ACTIONS")) {
39+
NSLog(@"Running in a GitHub Actions environment");
40+
}
3841
// Arguments to pass into the test suite runner.
3942
// argv[0] must identify the process; any subsequent arg
4043
// will be handled as if it were an argument to `python -m test`

Apple/testbed/__main__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import argparse
22
import json
3+
import os
34
import re
45
import shutil
56
import subprocess
@@ -78,13 +79,21 @@ def xcode_test(location: Path, platform: str, simulator: str, verbose: bool):
7879
check=True,
7980
)
8081

82+
# Any environment variable prefixed with TEST_RUNNER_ is exposed into the
83+
# test runner environment. There are some variables (like those identifying
84+
# CI platforms) that can be useful to have access to.
85+
test_env = os.environ.copy()
86+
if "GITHUB_ACTIONS" in os.environ:
87+
test_env["TEST_RUNNER_GITHUB_ACTIONS"] = os.environ["GITHUB_ACTIONS"]
88+
8189
print("Running test project...")
8290
# Test execution *can't* be run -quiet; verbose mode
8391
# is how we see the output of the test output.
8492
process = subprocess.Popen(
8593
["xcodebuild", "test-without-building"] + args,
8694
stdout=subprocess.PIPE,
8795
stderr=subprocess.STDOUT,
96+
env=test_env,
8897
)
8998
while line := (process.stdout.readline()).decode(*DECODE_ARGS):
9099
# Strip the timestamp/process prefix from each log line
@@ -412,4 +421,9 @@ def main():
412421

413422

414423
if __name__ == "__main__":
424+
# Under the buildbot, stdout is not a TTY, but we must still flush after
425+
# every line to make sure our output appears in the correct order relative
426+
# to the output of our subprocesses.
427+
for stream in [sys.stdout, sys.stderr]:
428+
stream.reconfigure(line_buffering=True)
415429
main()

Doc/c-api/arg.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ There are three ways strings and buffers can be converted to C:
160160
``w*`` (read-write :term:`bytes-like object`) [Py_buffer]
161161
This format accepts any object which implements the read-write buffer
162162
interface. It fills a :c:type:`Py_buffer` structure provided by the caller.
163-
The buffer may contain embedded null bytes. The caller have to call
163+
The buffer may contain embedded null bytes. The caller has to call
164164
:c:func:`PyBuffer_Release` when it is done with the buffer.
165165

166166
``es`` (:class:`str`) [const char \*encoding, char \*\*buffer]

Doc/c-api/capsule.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Refer to :ref:`using-capsules` for more information on using these objects.
1515
.. c:type:: PyCapsule
1616
1717
This subtype of :c:type:`PyObject` represents an opaque value, useful for C
18-
extension modules who need to pass an opaque value (as a :c:expr:`void*`
18+
extension modules which need to pass an opaque value (as a :c:expr:`void*`
1919
pointer) through Python code to other C code. It is often used to make a C
2020
function pointer defined in one module available to other modules, so the
2121
regular import mechanism can be used to access C APIs defined in dynamically

Doc/c-api/code.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ may change without deprecation warnings.
289289
290290
.. c:function:: Py_ssize_t PyUnstable_Eval_RequestCodeExtraIndex(freefunc free)
291291
292-
Return a new an opaque index value used to adding data to code objects.
292+
Return a new opaque index value used to adding data to code objects.
293293
294294
You generally call this function once (per interpreter) and use the result
295295
with ``PyCode_GetExtra`` and ``PyCode_SetExtra`` to manipulate

0 commit comments

Comments
 (0)