Skip to content

Commit aefe95b

Browse files
committed
Merge branch 'main' into 3.13
2 parents ffd4476 + 2f2f220 commit aefe95b

15 files changed

+636
-404
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
- uses: actions/[email protected]
110110

111111
- name: Set up Python
112-
uses: actions/setup-python@v5.3.0
112+
uses: actions/setup-python@v5.4.0
113113
with:
114114
# Appending -dev ensures that we can always build the dev release.
115115
# It's a no-op for versions that have been published.
@@ -121,7 +121,7 @@ jobs:
121121
make ${{ matrix.target }} BUILD_NUMBER=${{ needs.config.outputs.BUILD_NUMBER }}
122122
123123
- name: Upload build artefacts
124-
uses: actions/upload-artifact@v4.4.3
124+
uses: actions/upload-artifact@v4.6.0
125125
with:
126126
name: Python-${{ needs.config.outputs.PYTHON_VER }}-${{ matrix.target }}-support.${{ needs.config.outputs.BUILD_NUMBER }}.tar.gz
127127
path: dist/Python-${{ needs.config.outputs.PYTHON_VER }}-${{ matrix.target }}-support.${{ needs.config.outputs.BUILD_NUMBER }}.tar.gz

.github/workflows/publish.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212

1313
- name: Set up Python environment
14-
uses: actions/setup-python@v5.3.0
14+
uses: actions/setup-python@v5.4.0
1515
with:
1616
python-version: "3.X"
1717

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
merge-multiple: true
4848

4949
- name: Create Release
50-
uses: ncipollo/release-action@v1.14.0
50+
uses: ncipollo/release-action@v1.15.0
5151
with:
5252
name: ${{ needs.ci.outputs.PYTHON_VER }}-${{ needs.config.outputs.BUILD_NUMBER }}
5353
tag: ${{ needs.ci.outputs.PYTHON_VER }}-${{ needs.config.outputs.BUILD_NUMBER }}

Makefile

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ PYTHON_VER=$(basename $(PYTHON_VERSION))
2727
# The binary releases of dependencies, published at:
2828
# https://github.com/beeware/cpython-apple-source-deps/releases
2929
BZIP2_VERSION=1.0.8-1
30-
LIBFFI_VERSION=3.4.6-1
30+
LIBFFI_VERSION=3.4.7-1
3131
MPDECIMAL_VERSION=4.0.0-1
32-
OPENSSL_VERSION=3.0.15-1
33-
XZ_VERSION=5.6.2-1
32+
OPENSSL_VERSION=3.0.16-1
33+
XZ_VERSION=5.6.4-1
3434

3535
# Supported OS
3636
OS_LIST=macOS iOS tvOS watchOS
@@ -129,10 +129,10 @@ ARCH-$(target)=$$(subst .,,$$(suffix $(target)))
129129
ifneq ($(os),macOS)
130130
ifeq ($$(findstring simulator,$$(SDK-$(target))),)
131131
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))
132-
IS_SIMULATOR-$(target)="False"
132+
IS_SIMULATOR-$(target)=False
133133
else
134134
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))-simulator
135-
IS_SIMULATOR-$(target)="True"
135+
IS_SIMULATOR-$(target)=True
136136
endif
137137
endif
138138

@@ -261,6 +261,9 @@ PYTHON_LIB-$(target)=$$(PYTHON_FRAMEWORK-$(target))/Python
261261
PYTHON_BIN-$(target)=$$(PYTHON_INSTALL-$(target))/bin
262262
PYTHON_INCLUDE-$(target)=$$(PYTHON_FRAMEWORK-$(target))/Headers
263263
PYTHON_STDLIB-$(target)=$$(PYTHON_INSTALL-$(target))/lib/python$(PYTHON_VER)
264+
PYTHON_PLATFORM_CONFIG-$(target)=$$(PYTHON_INSTALL-$(target))/platform-config/$$(ARCH-$(target))-$$(SDK-$(target))
265+
PYTHON_PLATFORM_SITECUSTOMIZE-$(target)=$$(PYTHON_PLATFORM_CONFIG-$(target))/sitecustomize.py
266+
264267

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

322-
endif
323-
324-
PYTHON_SITECUSTOMIZE-$(target)=$(PROJECT_DIR)/support/$(PYTHON_VER)/$(os)/platform-site/$(target)/sitecustomize.py
325325

326-
$$(PYTHON_SITECUSTOMIZE-$(target)):
327-
@echo ">>> Create cross-platform sitecustomize.py for $(target)"
328-
mkdir -p $$(dir $$(PYTHON_SITECUSTOMIZE-$(target)))
329-
cat $(PROJECT_DIR)/patch/Python/sitecustomize.$(os).py \
326+
$$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)):
327+
@echo ">>> Create cross-plaform config for $(target)"
328+
mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(target))
329+
# Create the cross-platform site definition
330+
echo "import _cross_$$(ARCH-$(target))_$$(SDK-$(target)); import _cross_venv;" \
331+
> $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_venv.pth
332+
cp $(PROJECT_DIR)/patch/Python/make_cross_venv.py \
333+
$$(PYTHON_PLATFORM_CONFIG-$(target))/make_cross_venv.py
334+
cp $(PROJECT_DIR)/patch/Python/_cross_venv.py \
335+
$$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_venv.py
336+
cp $$(PYTHON_STDLIB-$(target))/_sysconfig* \
337+
$$(PYTHON_PLATFORM_CONFIG-$(target))
338+
cat $(PROJECT_DIR)/patch/Python/_cross_target.py.tmpl \
330339
| sed -e "s/{{os}}/$(os)/g" \
340+
| sed -e "s/{{platform}}/$$(OS_LOWER-$(target))/g" \
331341
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
342+
| sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \
332343
| sed -e "s/{{version_min}}/$$(VERSION_MIN-$(os))/g" \
333344
| sed -e "s/{{is_simulator}}/$$(IS_SIMULATOR-$(target))/g" \
334-
| sed -e "s/{{multiarch}}/$$(ARCH-$(target))-$$(SDK-$(target))/g" \
335-
| sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(SDK-$(target))/g" \
336-
> $$(PYTHON_SITECUSTOMIZE-$(target))
345+
> $$(PYTHON_PLATFORM_CONFIG-$(target))/_cross_$$(ARCH-$(target))_$$(SDK-$(target)).py
346+
cat $(PROJECT_DIR)/patch/Python/sitecustomize.py.tmpl \
347+
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
348+
| sed -e "s/{{sdk}}/$$(SDK-$(target))/g" \
349+
> $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target))
350+
351+
endif
337352

338-
$(target): $$(PYTHON_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target))
353+
$(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target))
339354

340355
###########################################################################
341356
# Target: Debug
@@ -364,6 +379,8 @@ vars-$(target):
364379
@echo "PYTHON_BIN-$(target): $$(PYTHON_BIN-$(target))"
365380
@echo "PYTHON_INCLUDE-$(target): $$(PYTHON_INCLUDE-$(target))"
366381
@echo "PYTHON_STDLIB-$(target): $$(PYTHON_STDLIB-$(target))"
382+
@echo "PYTHON_PLATFORM_CONFIG-$(target): $$(PYTHON_PLATFORM_CONFIG-$(target))"
383+
@echo "PYTHON_PLATFORM_SITECUSTOMIZE-$(target): $$(PYTHON_PLATFORM_SITECUSTOMIZE-$(target))"
367384
@echo
368385

369386
endef # build-target
@@ -424,6 +441,7 @@ PYTHON_LIB-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Python
424441
PYTHON_BIN-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/bin
425442
PYTHON_INCLUDE-$(sdk)=$$(PYTHON_FRAMEWORK-$(sdk))/Headers
426443
PYTHON_STDLIB-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/lib/python$(PYTHON_VER)
444+
PYTHON_PLATFORM_CONFIG-$(sdk)=$$(PYTHON_INSTALL-$(sdk))/platform-config
427445

428446
$$(PYTHON_LIB-$(sdk)): $$(foreach target,$$(SDK_TARGETS-$(sdk)),$$(PYTHON_LIB-$$(target)))
429447
@echo ">>> Build Python fat library for the $(sdk) SDK"
@@ -448,6 +466,9 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
448466
# Copy headers as-is from the first target in the $(sdk) SDK
449467
cp -r $$(PYTHON_INCLUDE-$$(firstword $$(SDK_TARGETS-$(sdk)))) $$(PYTHON_INCLUDE-$(sdk))
450468

469+
# Copy in the modulemap file
470+
cp -r patch/Python/module.modulemap $$(PYTHON_INCLUDE-$(sdk))
471+
451472
# Link the PYTHONHOME version of the headers
452473
mkdir -p $$(PYTHON_INSTALL-$(sdk))/include
453474
ln -si ../Python.framework/Headers $$(PYTHON_INSTALL-$(sdk))/include/python$(PYTHON_VER)
@@ -459,7 +480,7 @@ $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h: $$(PYTHON_LIB-$(sdk))
459480
cp $$(PYTHON_SRCDIR-$$(firstword $$(SDK_TARGETS-$(sdk))))/$(os)/Resources/pyconfig.h $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
460481

461482

462-
$$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-$(sdk))/Info.plist $$(PYTHON_INCLUDE-$(sdk))/pyconfig.h
483+
$$(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)))
463484
@echo ">>> Build Python stdlib for the $(sdk) SDK"
464485
mkdir -p $$(PYTHON_STDLIB-$(sdk))/lib-dynload
465486
# Copy stdlib from the first target associated with the $(sdk) SDK
@@ -474,6 +495,10 @@ $$(PYTHON_STDLIB-$(sdk))/LICENSE.TXT: $$(PYTHON_LIB-$(sdk)) $$(PYTHON_FRAMEWORK-
474495
# Copy the individual _sysconfigdata modules into names that include the architecture
475496
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp $$(PYTHON_STDLIB-$$(target))/_sysconfigdata_* $$(PYTHON_STDLIB-$(sdk))/; )
476497

498+
# Copy the platform site folders for each architecture
499+
mkdir -p $$(PYTHON_PLATFORM_CONFIG-$(sdk))
500+
$$(foreach target,$$(SDK_TARGETS-$(sdk)),cp -r $$(PYTHON_PLATFORM_CONFIG-$$(target)) $$(PYTHON_PLATFORM_CONFIG-$(sdk)); )
501+
477502
# Merge the binary modules from each target in the $(sdk) SDK into a single binary
478503
$$(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))); )
479504

@@ -558,6 +583,9 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
558583
# Rewrite the framework to make it standalone
559584
patch/make-relocatable.sh $$(PYTHON_INSTALL_VERSION-macosx) 2>&1 > /dev/null
560585

586+
# Copy in the modulemap file
587+
cp -r patch/Python/module.modulemap $$(PYTHON_FRAMEWORK-macosx)/Headers
588+
561589
# Re-apply the signature on the binaries.
562590
codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f $$(PYTHON_LIB-macosx) \
563591
2>&1 | tee $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
@@ -581,7 +609,7 @@ support/$(PYTHON_VER)/macOS/VERSIONS:
581609
dist/Python-$(PYTHON_VER)-macOS-support.$(BUILD_NUMBER).tar.gz: \
582610
$$(PYTHON_XCFRAMEWORK-macOS)/Info.plist \
583611
support/$(PYTHON_VER)/macOS/VERSIONS \
584-
$$(foreach target,$$(TARGETS-macOS), $$(PYTHON_SITECUSTOMIZE-$$(target)))
612+
$$(foreach target,$$(TARGETS-macOS), $$(PYTHON_PLATFORM_SITECUSTOMIZE-$$(target)))
585613

586614
@echo ">>> Create final distribution artefact for macOS"
587615
mkdir -p dist
@@ -604,9 +632,7 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
604632
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/include $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
605633
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/bin $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
606634
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/lib $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
607-
608-
@echo ">>> Create helper links in XCframework for $(os)"
609-
$$(foreach sdk,$$(SDKS-$(os)),ln -si $$(SDK_SLICE-$$(sdk)) $$(PYTHON_XCFRAMEWORK-$(os))/$$(sdk); )
635+
$$(foreach sdk,$$(SDKS-$(os)),cp -r $$(PYTHON_INSTALL-$$(sdk))/platform-config $$(PYTHON_XCFRAMEWORK-$(os))/$$(SDK_SLICE-$$(sdk)); )
610636

611637
ifeq ($(os),iOS)
612638
@echo ">>> Clone testbed project for $(os)"
@@ -626,7 +652,7 @@ endif
626652

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

631657
@echo ">>> Create final distribution artefact for $(os)"
632658
mkdir -p dist

README.rst

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ Each support package contains:
8383

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

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

99+
Each slice of an iOS/tvOS/watchOS XCframework also contains a
100+
``platform-config`` folder with a subfolder for each supported architecture in
101+
that slice. These subfolders can be used to make a macOS Python environment
102+
behave as if it were on an iOS/tvOS/watchOS device. This works in one of two
103+
ways:
104+
105+
1. **A sitecustomize.py script**. If the ``platform-config`` subfolder is on
106+
your ``PYTHONPATH`` when a Python interpreter is started, a site
107+
customization will be applied that patches methods in ``sys``, ``sysconfig``
108+
and ``platform`` that are used to identify the system.
109+
110+
2. **A make_cross_venv.py script**. If you call ``make_cross_venv.py``,
111+
providing the location of a virtual environment, the script will add some
112+
files to the ``site-packages`` folder of that environment that will
113+
automatically apply the same set of patches as the ``sitecustomize.py``
114+
script whenever the environment is activated, without any need to modify
115+
``PYTHONPATH``. If you use ``build`` to create an isolated PEP 517
116+
environment to build a wheel, these patches will also be applied to the
117+
isolated build environment that is created.
118+
119+
iOS distributions also contain a copy of the iOS ``testbed`` project - an Xcode
120+
project that can be used to run test suites of Python code. See the `CPython
121+
documentation on testing packages
122+
<https://docs.python.org/3/using/ios.html#testing-a-python-package>`__ for
123+
details on how to use this testbed.
124+
108125
For a detailed instructions on using the support package in your own project,
109126
see the `usage guide <./USAGE.md>`__
110127

0 commit comments

Comments
 (0)