Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0812d63
Rework naming of frameworks.
freakboy3742 Oct 14, 2023
6a363be
Correctly enforce minimum macOS version.
freakboy3742 Oct 19, 2023
c6808e5
Merge branch 'main' into 3.12
freakboy3742 Oct 27, 2023
2b0636c
Merge branch 'main' into 3.12
freakboy3742 Oct 27, 2023
30000e2
Merge branch 'main' into 3.12
freakboy3742 Aug 5, 2024
d92ed41
Update to Python 3.12.4.
freakboy3742 Aug 5, 2024
080a753
Merge branch 'main' into 3.12
freakboy3742 Aug 6, 2024
45e84f1
Merge branch 'main' into 3.12
freakboy3742 Aug 6, 2024
742bcc0
Merge branch 'main' into 3.12
freakboy3742 Aug 7, 2024
3a7f938
Merge branch 'main' into 3.12
freakboy3742 Sep 9, 2024
ce48e8b
Update patch to Python 3.12.6.
freakboy3742 Sep 9, 2024
c6eef37
Remove micro version from README note.
freakboy3742 Sep 9, 2024
1cb6fa3
Merge branch 'main' into 3.12
freakboy3742 Sep 10, 2024
9a461d6
Bump to 3.12.7.
freakboy3742 Oct 9, 2024
c89857a
Merge branch 'main' into 3.12
freakboy3742 Oct 28, 2024
ffd4476
Update patch to Python 3.13.1.
freakboy3742 Dec 13, 2024
d5b0f34
Update patch to Python 3.12.8.
freakboy3742 Dec 13, 2024
5ca1c79
Update build to use 3.14.0a3
freakboy3742 Dec 17, 2024
42a4a13
Bump actions/upload-artifact from 4.4.3 to 4.5.0
dependabot[bot] Dec 22, 2024
23ea419
Merge pull request #242 from beeware/dependabot/github_actions/action…
freakboy3742 Dec 22, 2024
dad62c3
Bump actions/upload-artifact from 4.5.0 to 4.6.0 (#244)
dependabot[bot] Jan 13, 2025
6d5096d
Bump ncipollo/release-action from 1.14.0 to 1.15.0 (#243)
dependabot[bot] Jan 13, 2025
a3ffcad
Update patch to 3.14.0a4.
freakboy3742 Feb 3, 2025
e6682a4
Bump actions/setup-python from 5.3.0 to 5.4.0 (#245)
dependabot[bot] Feb 3, 2025
a2c04c3
Bump patch to Python3.14.0a5. (#247)
freakboy3742 Feb 13, 2025
c82aa70
Modify handling of platform site to allow for venv usage. (#246)
freakboy3742 Feb 14, 2025
5cd3512
Improve support for PythonKit, and update usage guide (#248)
freakboy3742 Feb 14, 2025
2f2f220
More updates to USAGE and README (#250)
freakboy3742 Feb 17, 2025
aefe95b
Merge branch 'main' into 3.13
freakboy3742 Feb 18, 2025
1640499
Bump patch to 3.13.2.
freakboy3742 Feb 18, 2025
3a7cd86
More updates to USAGE and README (#250)
freakboy3742 Feb 17, 2025
1158013
Bump ncipollo/release-action from 1.15.0 to 1.16.0 (#253)
dependabot[bot] Feb 23, 2025
832d393
Bump actions/upload-artifact from 4.6.0 to 4.6.1 (#254)
dependabot[bot] Feb 23, 2025
aa545e9
Add patch for handling empty simulator lists.
freakboy3742 Feb 25, 2025
f2ab588
Add patch for handling empty simulator lists.
freakboy3742 Feb 25, 2025
c794b06
Bump actions/download-artifact from 4.1.8 to 4.1.9 (#255)
dependabot[bot] Mar 3, 2025
1bfa2a5
Merge branch 'main' into 3.12
freakboy3742 Mar 14, 2025
383a3e3
Update patch with recent Python main changes to iOS support.
freakboy3742 Mar 14, 2025
7ec320f
No need to run CI on pushes.
freakboy3742 Mar 14, 2025
9f467c7
Remove references to sysconfig_vars.json
freakboy3742 Mar 14, 2025
e16b12e
Update modulemap for 3.12.
freakboy3742 Mar 14, 2025
2696eb0
Add shim definitin of IOSVersionInfo.
freakboy3742 Mar 14, 2025
0daa79f
Add missing pyconfig headers to modulemap.
freakboy3742 Mar 14, 2025
0013ca0
Update patch for Python 3.14.0a6 (#258)
freakboy3742 Mar 18, 2025
47d6490
Update patch for 3.12.2
freakboy3742 Mar 18, 2025
97bfa9d
Merge latest changes from main workflow.
freakboy3742 Mar 18, 2025
1cb3c81
Update 3.11 patch with recent changes.
freakboy3742 Mar 18, 2025
4976f16
Correct some merge issues.
freakboy3742 Mar 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: CI
on:
pull_request:
push:
branches:
- main
- 3.*
workflow_call:
inputs:
build-number:
Expand Down Expand Up @@ -109,19 +105,22 @@ jobs:
- uses: actions/[email protected]

- name: Set up Python
uses: actions/setup-python@v5.3.0
uses: actions/setup-python@v5.4.0
with:
# Appending -dev ensures that we can always build the dev release.
# It's a no-op for versions that have been published.
python-version: ${{ needs.config.outputs.PYTHON_VER }}-dev
# Ensure that we *always* use the latest build, not a cached version.
# It's an edge case, but when a new alpha is released, we need to use it ASAP.
check-latest: true

- name: Build ${{ matrix.target }}
run: |
# Do the build for the requested target.
make ${{ matrix.target }} BUILD_NUMBER=${{ needs.config.outputs.BUILD_NUMBER }}

- name: Upload build artefacts
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.1
with:
name: Python-${{ needs.config.outputs.PYTHON_VER }}-${{ matrix.target }}-support.${{ needs.config.outputs.BUILD_NUMBER }}.tar.gz
path: dist/Python-${{ needs.config.outputs.PYTHON_VER }}-${{ matrix.target }}-support.${{ needs.config.outputs.BUILD_NUMBER }}.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v4

- name: Set up Python environment
uses: actions/setup-python@v5.3.0
uses: actions/setup-python@v5.4.0
with:
python-version: "3.X"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ jobs:
needs: [ config, ci ]
steps:
- name: Get build artifacts
uses: actions/[email protected].8
uses: actions/[email protected].9
with:
pattern: Python-*
path: dist
merge-multiple: true

- name: Create Release
uses: ncipollo/release-action@v1.14.0
uses: ncipollo/release-action@v1.16.0
with:
name: ${{ needs.ci.outputs.PYTHON_VER }}-${{ needs.config.outputs.BUILD_NUMBER }}
tag: ${{ needs.ci.outputs.PYTHON_VER }}-${{ needs.config.outputs.BUILD_NUMBER }}
Expand Down
92 changes: 63 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ PYTHON_VER=$(basename $(PYTHON_VERSION))
# The binary releases of dependencies, published at:
# https://github.com/beeware/cpython-apple-source-deps/releases
BZIP2_VERSION=1.0.8-1
LIBFFI_VERSION=3.4.6-1
LIBFFI_VERSION=3.4.7-1
MPDECIMAL_VERSION=4.0.0-1
OPENSSL_VERSION=3.0.15-1
XZ_VERSION=5.6.2-1
OPENSSL_VERSION=3.0.16-1
XZ_VERSION=5.6.4-1

# Supported OS
OS_LIST=macOS iOS tvOS watchOS
Expand All @@ -40,24 +40,18 @@ CURL_FLAGS=--disable --fail --location --create-dirs --progress-bar
# macOS targets
TARGETS-macOS=macosx.x86_64 macosx.arm64
VERSION_MIN-macOS=11.0
CFLAGS-macOS=-mmacosx-version-min=$(VERSION_MIN-macOS)

# iOS targets
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
VERSION_MIN-iOS=13.0
CFLAGS-iOS=-mios-version-min=$(VERSION_MIN-iOS)

# tvOS targets
TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
VERSION_MIN-tvOS=12.0
CFLAGS-tvOS=-mtvos-version-min=$(VERSION_MIN-tvOS)
PYTHON_CONFIGURE-tvOS=ac_cv_func_sigaltstack=no

# watchOS targets
TARGETS-watchOS=watchsimulator.x86_64 watchsimulator.arm64 watchos.arm64_32
VERSION_MIN-watchOS=4.0
CFLAGS-watchOS=-mwatchos-version-min=$(VERSION_MIN-watchOS)
PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack=no

# The architecture of the machine doing the build
HOST_ARCH=$(shell uname -m)
Expand All @@ -72,7 +66,7 @@ PATH=/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
all: $(OS_LIST)

.PHONY: \
all clean distclean update-patch vars \
all clean distclean update-patch vars config \
$(foreach os,$(OS_LIST),$(os) clean-$(os) dev-clean-$(os) vars-$(os)) \
$(foreach os,$(OS_LIST),$(foreach sdk,$$(sort $$(basename $$(TARGETS-$(os)))),$(sdk) vars-$(sdk)))
$(foreach os,$(OS_LIST),$(foreach target,$$(TARGETS-$(os)),$(target) vars-$(target)))
Expand Down Expand Up @@ -135,10 +129,10 @@ ARCH-$(target)=$$(subst .,,$$(suffix $(target)))
ifneq ($(os),macOS)
ifeq ($$(findstring simulator,$$(SDK-$(target))),)
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))
IS_SIMULATOR-$(target)="False"
IS_SIMULATOR-$(target)=False
else
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator
IS_SIMULATOR-$(target)="True"
IS_SIMULATOR-$(target)=True
endif
endif

Expand Down Expand Up @@ -267,6 +261,9 @@ PYTHON_LIB-$(target)=$$(PYTHON_FRAMEWORK-$(target))/Python
PYTHON_BIN-$(target)=$$(PYTHON_INSTALL-$(target))/bin
PYTHON_INCLUDE-$(target)=$$(PYTHON_FRAMEWORK-$(target))/Headers
PYTHON_STDLIB-$(target)=$$(PYTHON_INSTALL-$(target))/lib/python$(PYTHON_VER)
PYTHON_PLATFORM_CONFIG-$(target)=$$(PYTHON_INSTALL-$(target))/platform-config/$$(ARCH-$(target))-$$(SDK-$(target))
PYTHON_PLATFORM_SITECUSTOMIZE-$(target)=$$(PYTHON_PLATFORM_CONFIG-$(target))/sitecustomize.py


$$(PYTHON_SRCDIR-$(target))/configure: \
downloads/Python-$(PYTHON_VERSION).tar.gz \
Expand Down Expand Up @@ -325,23 +322,35 @@ $$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe
# Remove any .orig files produced by the compliance patching process
find $$(PYTHON_INSTALL-$(target)) -name "*.orig" -exec rm {} \;

endif

PYTHON_SITECUSTOMIZE-$(target)=$(PROJECT_DIR)/support/$(PYTHON_VER)/$(os)/platform-site/$(target)/sitecustomize.py

$$(PYTHON_SITECUSTOMIZE-$(target)):
@echo ">>> Create cross-platform sitecustomize.py for $(target)"
mkdir -p $$(dir $$(PYTHON_SITECUSTOMIZE-$(target)))
cat $(PROJECT_DIR)/patch/Python/sitecustomize.$(os).py \
$$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)):
@echo ">>> Create cross-plaform config for $(target)"
mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(target))
# Create the cross-platform site definition
echo "import _cross_$$(ARCH-$(target))_$$(SDK-$(target)); import _cross_venv;" \
> $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_venv.pth
cp $(PROJECT_DIR)/patch/Python/make_cross_venv.py \
$$(PYTHON_PLATFORM_CONFIG-$(target))/make_cross_venv.py
cp $(PROJECT_DIR)/patch/Python/_cross_venv.py \
$$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_venv.py
cp $$(PYTHON_STDLIB-$(target))/_sysconfig* \
$$(PYTHON_PLATFORM_CONFIG-$(target))
cat $(PROJECT_DIR)/patch/Python/_cross_target.py.tmpl \
| sed -e "s/{{os}}/$(os)/g" \
| sed -e "s/{{platform}}/$$(OS_LOWER-$(target))/g" \
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
| sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \
| sed -e "s/{{version_min}}/$$(VERSION_MIN-$(os))/g" \
| sed -e "s/{{is_simulator}}/$$(IS_SIMULATOR-$(target))/g" \
| sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(SDK-$(target))/g" \
| sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(SDK-$(target))/g" \
> $$(PYTHON_SITECUSTOMIZE-$(target))
> $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_$$(ARCH-$(target))_$$(SDK-$(target)).py
cat $(PROJECT_DIR)/patch/Python/sitecustomize.py.tmpl \
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
| sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \
> $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target))

endif

$(target): $$(PYTHON_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target))
$(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target))

###########################################################################
# Target: Debug
Expand Down Expand Up @@ -370,6 +379,8 @@ vars-$(target):
@echo "PYTHON_BIN-$(target): $$(PYTHON_BIN-$(target))"
@echo "PYTHON_INCLUDE-$(target): $$(PYTHON_INCLUDE-$(target))"
@echo "PYTHON_STDLIB-$(target): $$(PYTHON_STDLIB-$(target))"
@echo "PYTHON_PLATFORM_CONFIG-$(target): $$(PYTHON_PLATFORM_CONFIG-$(target))"
@echo "PYTHON_PLATFORM_SITECUSTOMIZE-$(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target))"
@echo

endef # build-target
Expand Down Expand Up @@ -415,6 +426,7 @@ PYTHON_FRAMEWORK-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/Python.framework
PYTHON_INSTALL_VERSION-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Versions/$(PYTHON_VER)
PYTHON_LIB-$(sdk)=$$(PYTHON_INSTALL_VERSION-$(sdk))/Python
PYTHON_INCLUDE-$(sdk)=$$(PYTHON_INSTALL_VERSION-$(sdk))/include/python$(PYTHON_VER)
PYTHON_MODULEMAP-$(sdk)=$$(PYTHON_INCLUDE-$(sdk))/module.modulemap
PYTHON_STDLIB-$(sdk)=$$(PYTHON_INSTALL_VERSION-$(sdk))/lib/python$(PYTHON_VER)

else
Expand All @@ -425,11 +437,13 @@ else
# The non-macOS frameworks don't use the versioning structure.

PYTHON_INSTALL-$(sdk)=$(PROJECT_DIR)/install/$(os)/$(sdk)/python-$(PYTHON_VERSION)
PYTHON_MODULEMAP-$(sdk)=$$(PYTHON_INCLUDE-$(sdk))/module.modulemap
PYTHON_FRAMEWORK-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/Python.framework
PYTHON_LIB-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Python
PYTHON_BIN-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/bin
PYTHON_INCLUDE-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Headers
PYTHON_STDLIB-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/lib/python$(PYTHON_VER)
PYTHON_PLATFORM_CONFIG-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/platform-config

$$(PYTHON_LIB-$(sdk)): $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_LIB-$$(target)))
@echo ">>> Build Python fat library for the $(sdk) SDK"
Expand All @@ -454,6 +468,15 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
# Copy headers as-is from the first target in the $(sdk) SDK
cp -r $$(PYTHON_INCLUDE-$$(firstword $$(SDK_TARGETS-$(sdk)))) $$(PYTHON_INCLUDE-$(sdk))

# Create the modulemap file
cp -r patch/Python/module.modulemap.prefix $$(PYTHON_MODULEMAP-$(sdk))
echo "" >> $$(PYTHON_MODULEMAP-$(sdk))
cd $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/Include && \
find cpython -name "*.h" | sort | sed -e 's/^/ exclude header "/' | sed 's/$$$$/"/' >> $$(PYTHON_MODULEMAP-$(sdk)) && \
echo "" >> $$(PYTHON_MODULEMAP-$(sdk)) && \
find internal -name "*.h" | sort | sed -e 's/^/ exclude header "/' | sed 's/$$$$/"/' >> $$(PYTHON_MODULEMAP-$(sdk))
echo "\n}" >> $$(PYTHON_MODULEMAP-$(sdk))

# Link the PYTHONHOME version of the headers
mkdir -p $$(PYTHON_INSTALL-$(sdk))/include
ln -si ../Python.framework/Headers $$(PYTHON_INSTALL-$(sdk))/include/python$(PYTHON_VER)
Expand All @@ -465,7 +488,7 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h


$$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-$(sdk))/Info.plist $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
$$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-$(sdk))/Info.plist $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))
@echo ">>> Build Python stdlib for the $(sdk) SDK"
mkdir -p $$(PYTHON_STDLIB-$(sdk))/lib-dynload
# Copy stdlib from the first target associated with the $(sdk) SDK
Expand All @@ -480,6 +503,10 @@ $$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-
# Copy the individual _sysconfigdata modules into names that include the architecture
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_STDLIB-$$(target))/_sysconfigdata_* $$(PYTHON_STDLIB-$(sdk))/; )

# Copy the platform site folders for each architecture
mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(sdk))
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp -r $$(PYTHON_PLATFORM_CONFIG-$$(target)) $$(PYTHON_PLATFORM_CONFIG-$(sdk)); )

# Merge the binary modules from each target in the $(sdk) SDK into a single binary
$$(foreach module,$$(wildcard $$(PYTHON_STDLIB-$$(firstword $$(SDK_TARGETS-$(sdk))))/lib-dynload/*),lipo -create -output $$(PYTHON_STDLIB-$(sdk))/lib-dynload/$$(notdir $$(module)) $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_STDLIB-$$(target))/lib-dynload/$$(notdir $$(module))); )

Expand Down Expand Up @@ -564,6 +591,15 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
# Rewrite the framework to make it standalone
patch/make-relocatable.sh $$(PYTHON_INSTALL_VERSION-macosx) 2>&1 > /dev/null

# Create the modulemap file
cp -r patch/Python/module.modulemap.prefix $$(PYTHON_MODULEMAP-macosx)
echo "" >> $$(PYTHON_MODULEMAP-macosx)
cd $$(PYTHON_INCLUDE-macosx) && \
find cpython -name "*.h" | sort | sed -e 's/^/ exclude header "/' | sed 's/$$$$/"/' >> $$(PYTHON_MODULEMAP-macosx) && \
echo "" >> $$(PYTHON_MODULEMAP-macosx) && \
find internal -name "*.h" | sort | sed -e 's/^/ exclude header "/' | sed 's/$$$$/"/' >> $$(PYTHON_MODULEMAP-macosx)
echo "\n}" >> $$(PYTHON_MODULEMAP-macosx)

# Re-apply the signature on the binaries.
codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f $$(PYTHON_LIB-macosx) \
2>&1 | tee $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
Expand All @@ -587,7 +623,7 @@ support/$(PYTHON_VER)/macOS/VERSIONS:
dist/Python-$(PYTHON_VER)-macOS-support.$(BUILD_NUMBER).tar.gz: \
$$(PYTHON_XCFRAMEWORK-macOS)/Info.plist \
support/$(PYTHON_VER)/macOS/VERSIONS \
$$(foreach target,$$(TARGETS-macOS), $$(PYTHON_SITECUSTOMIZE-$$(target)))
$$(foreach target,$$(TARGETS-macOS), $$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))

@echo ">>> Create final distribution artefact for macOS"
mkdir -p dist
Expand All @@ -610,9 +646,7 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/include $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/bin $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/lib $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )

@echo ">>> Create helper links in XCframework for $(os)"
$$(foreach sdk,$$(SDKS-$(os)),ln -si $$(SDK_SLICE-$$(sdk)) $$(PYTHON_XCFRAMEWORK-$(os))/$$(sdk); )
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/platform-config $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )

ifeq ($(os),iOS)
@echo ">>> Clone testbed project for $(os)"
Expand All @@ -632,7 +666,7 @@ endif

dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \
$$(PYTHON_XCFRAMEWORK-$(os))/Info.plist \
$$(foreach target,$$(TARGETS-$(os)), $$(PYTHON_SITECUSTOMIZE-$$(target)))
$$(foreach target,$$(TARGETS-$(os)), $$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))

@echo ">>> Create final distribution artefact for $(os)"
mkdir -p dist
Expand Down
35 changes: 26 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,6 @@ Each support package contains:

* ``VERSIONS``, a text file describing the specific versions of code used to build the
support package;
* ``platform-site``, a folder that contains site customization scripts that can be used
to make your local Python install look like it is an on-device install for each of the
underlying target architectures supported by the platform. This is needed because when
you run ``pip`` you'll be on a macOS machine with a specific architecture; if ``pip``
tries to install a binary package, it will install a macOS binary wheel (which won't
work on iOS/tvOS/watchOS). However, if you add the ``platform-site`` folder to your
``PYTHONPATH`` when invoking pip, the site customization will make your Python install
return ``platform`` and ``sysconfig`` responses consistent with on-device behavior,
which will cause ``pip`` to install platform-appropriate packages.
* ``Python.xcframework``, a multi-architecture build of the Python runtime library

On iOS/tvOS/watchOS, the ``Python.xcframework`` contains a
Expand All @@ -105,6 +96,32 @@ needed to build packages. This is required because Xcode uses the ``xcrun``
alias to dynamically generate the name of binaries, but a lot of C tooling
expects that ``CC`` will not contain spaces.

Each slice of an iOS/tvOS/watchOS XCframework also contains a
``platform-config`` folder with a subfolder for each supported architecture in
that slice. These subfolders can be used to make a macOS Python environment
behave as if it were on an iOS/tvOS/watchOS device. This works in one of two
ways:

1. **A sitecustomize.py script**. If the ``platform-config`` subfolder is on
your ``PYTHONPATH`` when a Python interpreter is started, a site
customization will be applied that patches methods in ``sys``, ``sysconfig``
and ``platform`` that are used to identify the system.

2. **A make_cross_venv.py script**. If you call ``make_cross_venv.py``,
providing the location of a virtual environment, the script will add some
files to the ``site-packages`` folder of that environment that will
automatically apply the same set of patches as the ``sitecustomize.py``
script whenever the environment is activated, without any need to modify
``PYTHONPATH``. If you use ``build`` to create an isolated PEP 517
environment to build a wheel, these patches will also be applied to the
isolated build environment that is created.

iOS distributions also contain a copy of the iOS ``testbed`` project - an Xcode
project that can be used to run test suites of Python code. See the `CPython
documentation on testing packages
<https://docs.python.org/3/using/ios.html#testing-a-python-package>`__ for
details on how to use this testbed.

For a detailed instructions on using the support package in your own project,
see the `usage guide <./USAGE.md>`__

Expand Down
Loading