Migrate the Apple/iOS XCframework build tools to the Platforms directory.
sudo xcode-select --switch /Applications/Xcode_15.4.app
- name: Build and test
- run: python3 Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
+ run: python3 Platforms/Apple ci iOS --fast-ci --simulator 'iPhone SE (3rd generation),OS=17.5'
build-emscripten:
name: 'Emscripten'
rev: a27a2e47c7751b639d2b5badf0ef6ff11fee893f # frozen: v0.15.4
hooks:
- id: ruff-check
- name: Run Ruff (lint) on Apple/
- args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
- files: ^Apple/
+ name: Run Ruff (lint) on Platforms/Apple/
+ args: [--exit-non-zero-on-fix, --config=Platforms/Apple/.ruff.toml]
+ files: ^Platforms/Apple/
- id: ruff-check
name: Run Ruff (lint) on Doc/
args: [--exit-non-zero-on-fix]
args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
files: ^Tools/wasm/
- id: ruff-format
- name: Run Ruff (format) on Apple/
- args: [--exit-non-zero-on-fix, --config=Apple/.ruff.toml]
- files: ^Apple
+ name: Run Ruff (format) on Platforms/Apple/
+ args: [--exit-non-zero-on-fix, --config=Platforms/Apple/.ruff.toml]
+ files: ^Platforms/Apple/
- id: ruff-format
name: Run Ruff (format) on Doc/
args: [--exit-non-zero-on-fix]
fi
# Clone the testbed project into the XCFOLDER
- $(PYTHON_FOR_BUILD) $(srcdir)/Apple/testbed clone --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)"
+ $(PYTHON_FOR_BUILD) $(srcdir)/Platforms/Apple/testbed clone --framework $(PYTHONFRAMEWORKPREFIX) "$(XCFOLDER)"
# Run the testbed project
$(PYTHON_FOR_BUILD) "$(XCFOLDER)" run --verbose -- test -uall --single-process --rerun -W --pythoninfo
-find build -type f -a ! -name '*.gc??' -exec rm -f {} ';'
-rm -f Include/pydtrace_probes.h
-rm -f profile-gen-stamp
- -rm -rf Apple/iOS/testbed/Python.xcframework/ios-*/bin
- -rm -rf Apple/iOS/testbed/Python.xcframework/ios-*/lib
- -rm -rf Apple/iOS/testbed/Python.xcframework/ios-*/include
- -rm -rf Apple/iOS/testbed/Python.xcframework/ios-*/Python.framework
+ -rm -rf Platforms/Apple/iOS/testbed/Python.xcframework/ios-*/bin
+ -rm -rf Platforms/Apple/iOS/testbed/Python.xcframework/ios-*/lib
+ -rm -rf Platforms/Apple/iOS/testbed/Python.xcframework/ios-*/include
+ -rm -rf Platforms/Apple/iOS/testbed/Python.xcframework/ios-*/Python.framework
.PHONY: profile-removal
profile-removal:
config.cache config.log pyconfig.h Modules/config.c
-rm -rf build platform
-rm -rf $(PYTHONFRAMEWORKDIR)
- -rm -rf Apple/iOS/Frameworks
+ -rm -rf Platforms/Apple/iOS/Frameworks
-rm -rf iOSTestbed.*
-rm -f python-config.py python-config
-rm -rf cross-build
--- /dev/null
+The Apple/iOS build script has been moved to the Platforms directory.
-extend = "../.ruff.toml" # Inherit the project-wide settings
+extend = "../../.ruff.toml" # Inherit the project-wide settings
[format]
preview = true
#
# The simplest entry point is:
#
-# $ python Apple ci iOS
+# $ python Platforms/Apple ci iOS
#
# which will:
# * Clean any pre-existing build artefacts
ArgsT = Sequence[str | Path]
SCRIPT_NAME = Path(__file__).name
-PYTHON_DIR = Path(__file__).resolve().parent.parent
+PYTHON_DIR = Path(__file__).resolve().parent.parent.parent
CROSS_BUILD_DIR = PYTHON_DIR / "cross-build"
"""Construct an Apple development environment for the given host."""
env = {
"PATH": ":".join([
- str(PYTHON_DIR / "Apple/iOS/Resources/bin"),
+ str(PYTHON_DIR / "Platforms/Apple/iOS/Resources/bin"),
str(subdir(host) / "prefix"),
"/usr/bin",
"/bin",
:param host_triple: The host triple (e.g., arm64-apple-ios-simulator)
:param multiarch: The multiarch identifier (e.g., arm64-simulator)
"""
- return CROSS_BUILD_DIR / f"{host_triple}/Apple/iOS/Frameworks/{multiarch}"
+ return (
+ CROSS_BUILD_DIR
+ / f"{host_triple}/Platforms/Apple/iOS/Frameworks/{multiarch}"
+ )
def package_version(prefix_path: Path) -> str:
# Copy in the cross-architecture pyconfig.h
shutil.copy(
- PYTHON_DIR / f"Apple/{platform}/Resources/pyconfig.h",
+ PYTHON_DIR / f"Platforms/Apple/{platform}/Resources/pyconfig.h",
slice_framework / "Headers/pyconfig.h",
)
host_path = (
CROSS_BUILD_DIR
/ host_triple
- / "Apple/iOS/Frameworks"
+ / "Platforms/Apple/iOS/Frameworks"
/ multiarch
)
host_framework = host_path / "Python.framework"
print(" - build tools")
shutil.copytree(
- PYTHON_DIR / "Apple/testbed/Python.xcframework/build",
+ PYTHON_DIR / "Platforms/Apple/testbed/Python.xcframework/build",
package_path / "Python.xcframework/build",
)
print()
run([
sys.executable,
- "Apple/testbed",
+ "Platforms/Apple/testbed",
"clone",
"--platform",
context.platform,
framework_path = (
CROSS_BUILD_DIR
/ host
- / f"Apple/{context.platform}"
+ / f"Platforms/Apple/{context.platform}"
/ f"Frameworks/{apple_multiarch(host)}"
)
run([
sys.executable,
- "Apple/testbed",
+ "Platforms/Apple/testbed",
"clone",
"--platform",
context.platform,
### Building a multi-architecture iOS XCframework
-The `Apple` subfolder of the Python repository acts as a build script that
+The `Platforms/Apple` subfolder of the Python repository acts as a build script that
can be used to coordinate the compilation of a complete iOS XCframework. To use
it, run::
- python Apple build iOS
+ python Platforms/Apple build iOS
This will:
the `Python.xcframework`, plus a copy of the Testbed app pre-configured to
use the XCframework.
-The `Apple` build script has other entry points that will perform the
+The `Platforms/Apple` build script has other entry points that will perform the
individual parts of the overall `build` target, plus targets to test the
build, clean the `cross-build` folder of iOS build products, and perform a
complete "build and test" CI run. The `--clean` flag can also be used on
### Building a single-architecture framework
-If you're using the `Apple` build script, you won't need to build
+If you're using the `Platforms/Apple` build script, you won't need to build
individual frameworks. However, if you do need to manually configure an iOS
Python build for a single framework, the following options are available.
> [!NOTE]
> Unless you know what you're doing, changing the name of the Python
> framework on iOS is not advised. If you use this option, you won't be able
- > to run the `Apple` build script without making significant manual
+ > to run the `Platforms/Apple` build script without making significant manual
> alterations, and you won't be able to use any binary packages unless you
> compile them yourself using your own framework name.
also requires the use of cross-compilation. The minimal commands for building
Python for the ARM64 iOS simulator will look something like:
```
-export PATH="$(pwd)/Apple/iOS/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
+export PATH="$(pwd)/Platforms/Apple/iOS/Resources/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin"
./configure \
--enable-framework \
--host=arm64-apple-ios-simulator \
In this invocation:
-* `Apple/iOS/Resources/bin` has been added to the path, providing some shims for the
+* `Platforms/Apple/iOS/Resources/bin` has been added to the path, providing some shims for the
compilers and linkers needed by the build. Xcode requires the use of `xcrun`
to invoke compiler tooling. However, if `xcrun` is pre-evaluated and the
result passed to `configure`, these results can embed user- and
cause significant problems with many C configuration systems which assume that
`CC` will be a single executable.
- To work around this problem, the `Apple/iOS/Resources/bin` folder contains some
+ To work around this problem, the `Platforms/Apple/iOS/Resources/bin` folder contains some
wrapper scripts that present as simple compilers and linkers, but wrap
underlying calls to `xcrun`. This allows configure to use a `CC`
definition without spaces, and without user- or version-specific paths, while
Once you have a built an XCframework, you can test that framework by running:
- $ python Apple test iOS
+ $ python Platforms/Apple test iOS
This test will attempt to find an "SE-class" simulator (i.e., an iPhone SE, or
iPhone 16e, or similar), and run the test suite on the most recent version of
### Testing a single-architecture framework
-The `Apple/testbed` folder that contains an Xcode project that is able to run
+The `Platforms/Apple/testbed` folder that contains an Xcode project that is able to run
the Python test suite on Apple platforms. This project converts the Python test
suite into a single test case in Xcode's XCTest framework. The single XCTest
passes if the test suite passes.
To run the test suite, configure a Python build for an iOS simulator (i.e.,
`--host=arm64-apple-ios-simulator` or `--host=x86_64-apple-ios-simulator`
), specifying a framework build (i.e. `--enable-framework`). Ensure that your
-`PATH` has been configured to include the `Apple/iOS/Resources/bin` folder and
+`PATH` has been configured to include the `Platforms/Apple/iOS/Resources/bin` folder and
exclude any non-iOS tools, then run:
```
make all
### Debugging test failures
-Running `python Apple test iOS` generates a standalone version of the
-`Apple/testbed` project, and runs the full test suite. It does this using
-`Apple/testbed` itself - the folder is an executable module that can be used
+Running `python Platforms/Apple test iOS` generates a standalone version of the
+`Platforms/Apple/testbed` project, and runs the full test suite. It does this using
+`Platforms/Apple/testbed` itself - the folder is an executable module that can be used
to create and run a clone of the testbed project. The standalone version of the
testbed will be created in a directory named
`cross-build/iOS-testbed.<timestamp>`.
If you've built your own XCframework, or you only want to test a single architecture,
you can construct a standalone testbed instance by running:
```
-python Apple/testbed clone --platform iOS --framework <path/to/framework> my-testbed
+python Platforms/Apple/testbed clone --platform iOS --framework <path/to/framework> my-testbed
```
The framework path can be the path path to a `Python.xcframework`, or the
yes)
case $ac_sys_system in
Darwin) enableval=/Library/Frameworks ;;
- iOS) enableval=Apple/iOS/Frameworks/\$\(MULTIARCH\) ;;
+ iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;;
*) as_fn_error $? "Unknown platform for framework build" "$LINENO" 5
esac
esac
prefix=$PYTHONFRAMEWORKPREFIX
PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR"
- RESSRCDIR=Apple/iOS/Resources
+ RESSRCDIR=Platforms/Apple/iOS/Resources
- ac_config_files="$ac_config_files Apple/iOS/Resources/Info.plist"
+ ac_config_files="$ac_config_files Platforms/Apple/iOS/Resources/Info.plist"
;;
*)
"Mac/PythonLauncher/Makefile") CONFIG_FILES="$CONFIG_FILES Mac/PythonLauncher/Makefile" ;;
"Mac/Resources/framework/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/framework/Info.plist" ;;
"Mac/Resources/app/Info.plist") CONFIG_FILES="$CONFIG_FILES Mac/Resources/app/Info.plist" ;;
- "Apple/iOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Apple/iOS/Resources/Info.plist" ;;
+ "Platforms/Apple/iOS/Resources/Info.plist") CONFIG_FILES="$CONFIG_FILES Platforms/Apple/iOS/Resources/Info.plist" ;;
"Makefile.pre") CONFIG_FILES="$CONFIG_FILES Makefile.pre" ;;
"Misc/python.pc") CONFIG_FILES="$CONFIG_FILES Misc/python.pc" ;;
"Misc/python-embed.pc") CONFIG_FILES="$CONFIG_FILES Misc/python-embed.pc" ;;
yes)
case $ac_sys_system in
Darwin) enableval=/Library/Frameworks ;;
- iOS) enableval=Apple/iOS/Frameworks/\$\(MULTIARCH\) ;;
+ iOS) enableval=Platforms/Apple/iOS/Frameworks/\$\(MULTIARCH\) ;;
*) AC_MSG_ERROR([Unknown platform for framework build])
esac
esac
prefix=$PYTHONFRAMEWORKPREFIX
PYTHONFRAMEWORKINSTALLNAMEPREFIX="@rpath/$PYTHONFRAMEWORKDIR"
- RESSRCDIR=Apple/iOS/Resources
+ RESSRCDIR=Platforms/Apple/iOS/Resources
- AC_CONFIG_FILES([Apple/iOS/Resources/Info.plist])
+ AC_CONFIG_FILES([Platforms/Apple/iOS/Resources/Info.plist])
;;
*)
AC_MSG_ERROR([Unknown platform for framework build])