Skip to content

Commit c53d7bd

Browse files
committed
Update to final state of PEP730 patches.
1 parent 493dc76 commit c53d7bd

File tree

8 files changed

+1436
-5298
lines changed

8 files changed

+1436
-5298
lines changed

Makefile

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ BUILD_NUMBER=custom
1515
# PYTHON_VERSION is the full version number (e.g., 3.10.0b3)
1616
# PYTHON_MICRO_VERSION is the full version number, without any alpha/beta/rc suffix. (e.g., 3.10.0)
1717
# PYTHON_VER is the major/minor version (e.g., 3.10)
18-
PYTHON_VERSION=3.13.0a1
18+
PYTHON_VERSION=3.13.0b4
1919
PYTHON_MICRO_VERSION=$(shell echo $(PYTHON_VERSION) | grep -Eo "\d+\.\d+\.\d+")
2020
PYTHON_VER=$(basename $(PYTHON_VERSION))
2121

2222
# The binary releases of dependencies, published at:
2323
# https://github.com/beeware/cpython-apple-source-deps/releases
2424
BZIP2_VERSION=1.0.8-1
25-
XZ_VERSION=5.4.4-1
26-
OPENSSL_VERSION=3.0.12-1
27-
LIBFFI_VERSION=3.4.4-1
25+
MPDECIMAL_VERSION=4.0.0-1
26+
OPENSSL_VERSION=3.0.14-1
27+
XZ_VERSION=5.4.7-1
28+
LIBFFI_VERSION=3.4.6-1
2829

2930
# Supported OS
3031
OS_LIST=macOS iOS tvOS watchOS
@@ -37,17 +38,15 @@ VERSION_MIN-macOS=11.0
3738

3839
# iOS targets
3940
TARGETS-iOS=iphonesimulator.x86_64 iphonesimulator.arm64 iphoneos.arm64
40-
VERSION_MIN-iOS=12.0
41+
VERSION_MIN-iOS=13.0
4142

4243
# tvOS targets
4344
TARGETS-tvOS=appletvsimulator.x86_64 appletvsimulator.arm64 appletvos.arm64
44-
VERSION_MIN-tvOS=9.0
45-
PYTHON_CONFIGURE-tvOS=ac_cv_func_sigaltstack=no
45+
VERSION_MIN-tvOS=12.0
4646

4747
# watchOS targets
4848
TARGETS-watchOS=watchsimulator.x86_64 watchsimulator.arm64 watchos.arm64_32
4949
VERSION_MIN-watchOS=4.0
50-
PYTHON_CONFIGURE-watchOS=ac_cv_func_sigaltstack=no
5150

5251
# The architecture of the machine doing the build
5352
HOST_ARCH=$(shell uname -m)
@@ -82,7 +81,7 @@ update-patch:
8281
# call
8382
if [ -z "$(PYTHON_REPO_DIR)" ]; then echo "\n\nPYTHON_REPO_DIR must be set to the root of your Python github checkout\n\n"; fi
8483
cd $(PYTHON_REPO_DIR) && \
85-
git diff -D v$(PYTHON_VERSION) $(PYTHON_VER) \
84+
git diff -D v$(PYTHON_VERSION) $(PYTHON_VER)-patched \
8685
| PATH="/usr/local/bin:/opt/homebrew/bin:$(PATH)" filterdiff \
8786
-X $(PROJECT_DIR)/patch/Python/diff.exclude -p 1 --clean \
8887
> $(PROJECT_DIR)/patch/Python/Python.patch
@@ -122,8 +121,6 @@ OS_LOWER-$(target)=$(shell echo $(os) | tr '[:upper:]' '[:lower:]')
122121
SDK-$(target)=$$(basename $(target))
123122
ARCH-$(target)=$$(subst .,,$$(suffix $(target)))
124123

125-
WHEEL_TAG-$(target)=py3-none-$$(shell echo $$(OS_LOWER-$(target))_$$(VERSION_MIN-$(os))_$(target) | sed "s/\./_/g")
126-
127124
ifneq ($(os),macOS)
128125
ifeq ($$(findstring simulator,$$(SDK-$(target))),)
129126
TARGET_TRIPLE-$(target)=$$(ARCH-$(target))-apple-$$(OS_LOWER-$(target))$$(VERSION_MIN-$(os))
@@ -176,6 +173,26 @@ $$(XZ_LIB-$(target)): downloads/xz-$(XZ_VERSION)-$(target).tar.gz
176173
# Ensure the target is marked as clean.
177174
touch $$(XZ_LIB-$(target))
178175

176+
###########################################################################
177+
# Target: mpdecimal
178+
###########################################################################
179+
180+
MPDECIMAL_INSTALL-$(target)=$(PROJECT_DIR)/install/$(os)/$(target)/mpdecimal-$(MPDECIMAL_VERSION)
181+
MPDECIMAL_LIB-$(target)=$$(MPDECIMAL_INSTALL-$(target))/lib/libmpdec.a
182+
183+
downloads/mpdecimal-$(MPDECIMAL_VERSION)-$(target).tar.gz:
184+
@echo ">>> Download mpdecimal for $(target)"
185+
mkdir -p downloads
186+
curl $(CURL_FLAGS) -o $$@ \
187+
https://github.com/beeware/cpython-apple-source-deps/releases/download/mpdecimal-$(MPDECIMAL_VERSION)/mpdecimal-$(MPDECIMAL_VERSION)-$(target).tar.gz
188+
189+
$$(MPDECIMAL_LIB-$(target)): downloads/mpdecimal-$(MPDECIMAL_VERSION)-$(target).tar.gz
190+
@echo ">>> Install mpdecimal for $(target)"
191+
mkdir -p $$(MPDECIMAL_INSTALL-$(target))
192+
cd $$(MPDECIMAL_INSTALL-$(target)) && tar zxvf $(PROJECT_DIR)/downloads/mpdecimal-$(MPDECIMAL_VERSION)-$(target).tar.gz
193+
# Ensure the target is marked as clean.
194+
touch $$(MPDECIMAL_LIB-$(target))
195+
179196
###########################################################################
180197
# Target: OpenSSL
181198
###########################################################################
@@ -245,6 +262,7 @@ $$(PYTHON_SRCDIR-$(target))/configure: \
245262
$$(BZIP2_LIB-$(target)) \
246263
$$(XZ_LIB-$(target)) \
247264
$$(OPENSSL_SSL_LIB-$(target)) \
265+
$$(MPDECIMAL_LIB-$(target)) \
248266
$$(LIBFFI_LIB-$(target))
249267
@echo ">>> Unpack and configure Python for $(target)"
250268
mkdir -p $$(PYTHON_SRCDIR-$(target))
@@ -270,25 +288,24 @@ $$(PYTHON_SRCDIR-$(target))/Makefile: \
270288
LIBLZMA_LIBS="-L$$(XZ_INSTALL-$(target))/lib -llzma" \
271289
BZIP2_CFLAGS="-I$$(BZIP2_INSTALL-$(target))/include" \
272290
BZIP2_LIBS="-L$$(BZIP2_INSTALL-$(target))/lib -lbz2" \
291+
LIBMPDEC_CFLAGS="-I$$(MPDECIMAL_INSTALL-$(target))/include" \
292+
LIBMPDEC_LIBS="-L$$(MPDECIMAL_INSTALL-$(target))/lib -lmpdec" \
273293
LIBFFI_CFLAGS="-I$$(LIBFFI_INSTALL-$(target))/include" \
274294
LIBFFI_LIBS="-L$$(LIBFFI_INSTALL-$(target))/lib -lffi" \
275295
--host=$$(TARGET_TRIPLE-$(target)) \
276296
--build=$(HOST_ARCH)-apple-darwin \
277297
--with-build-python=$(HOST_PYTHON) \
278298
--enable-ipv6 \
279299
--with-openssl="$$(OPENSSL_INSTALL-$(target))" \
280-
--without-ensurepip \
281300
--enable-framework="$$(PYTHON_INSTALL-$(target))" \
282-
ac_cv_file__dev_ptmx=no \
283-
ac_cv_file__dev_ptc=no \
284-
$$(PYTHON_CONFIGURE-$(os)) \
301+
--with-system-libmpdec \
285302
2>&1 | tee -a ../python-$(PYTHON_VERSION).config.log
286303

287304
$$(PYTHON_SRCDIR-$(target))/python.exe: $$(PYTHON_SRCDIR-$(target))/Makefile
288305
@echo ">>> Build Python for $(target)"
289306
cd $$(PYTHON_SRCDIR-$(target)) && \
290307
PATH="$(PROJECT_DIR)/$$(PYTHON_SRCDIR-$(target))/$(os)/Resources/bin:$(PATH)" \
291-
make all \
308+
make -j8 all \
292309
2>&1 | tee -a ../python-$(PYTHON_VERSION).build.log
293310

294311
$$(PYTHON_LIB-$(target)): $$(PYTHON_SRCDIR-$(target))/python.exe
@@ -308,7 +325,7 @@ $$(PYTHON_SITECUSTOMIZE-$(target)):
308325
cat $(PROJECT_DIR)/patch/Python/sitecustomize.$(os).py \
309326
| sed -e "s/{{os}}/$(os)/g" \
310327
| sed -e "s/{{arch}}/$$(ARCH-$(target))/g" \
311-
| sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(SDK-$(target))-$$(ARCH-$(target))/g" \
328+
| sed -e "s/{{tag}}/$$(OS_LOWER-$(target))-$$(VERSION_MIN-$(os))-$$(ARCH-$(target))-$$(SDK-$(target))/g" \
312329
> $$(PYTHON_SITECUSTOMIZE-$(target))
313330

314331
$(target): $$(PYTHON_SITECUSTOMIZE-$(target)) $$(PYTHON_LIB-$(target))
@@ -329,6 +346,8 @@ vars-$(target):
329346
@echo "XZ_LIB-$(target): $$(XZ_LIB-$(target))"
330347
@echo "OPENSSL_INSTALL-$(target): $$(OPENSSL_INSTALL-$(target))"
331348
@echo "OPENSSL_SSL_LIB-$(target): $$(OPENSSL_SSL_LIB-$(target))"
349+
@echo "MPDECIMAL_INSTALL-$(target): $$(MPDECIMAL_INSTALL-$(target))"
350+
@echo "MPDECIMAL_LIB-$(target): $$(MPDECIMAL_LIB-$(target))"
332351
@echo "LIBFFI_INSTALL-$(target): $$(LIBFFI_INSTALL-$(target))"
333352
@echo "LIBFFI_LIB-$(target): $$(LIBFFI_LIB-$(target))"
334353
@echo "PYTHON_SRCDIR-$(target): $$(PYTHON_SRCDIR-$(target))"
@@ -524,20 +543,14 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
524543
tar zxf build/macOS/macosx/python-$(PYTHON_VERSION)/Python_Framework.pkgPython_Framework.pkg/PayloadPython_Framework.pkgPython_Framework.pkg/PayloadPython_Framework.pkgPython_Framework.pkg/Payload -C $$(PYTHON_FRAMEWORK-macosx) -X patch/Python/release.macOS.exclude
525544

526545
# Rewrite the framework to make it standalone
527-
python3 patch/make-macho-standalone.py $$(PYTHON_FRAMEWORK-macosx) \
528-
2>&1 | tee $$(PYTHON_INSTALL-macosx)/python-$(PY_VERSION).make-macho-standalone.log
529-
530-
# Remove the "development" versions of the libs
531-
rm -f $$(PYTHON_INSTALL_VERSION-macosx)/lib/*.dylib
532-
rm -f $$(PYTHON_INSTALL_VERSION-macosx)/lib/*.a
533-
rm -rf $$(PYTHON_INSTALL_VERSION-macosx)/lib/python$(PY_VERSION)/config-*
546+
patch/make-relocatable.sh $$(PYTHON_INSTALL_VERSION-macosx) 2>&1 > /dev/null
534547

535548
# Re-apply the signature on the binaries.
536549
codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f $$(PYTHON_LIB-macosx) \
537550
2>&1 | tee $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
538-
find install/macOS/macosx/python-3.13.0a1/Python.framework -name "*.dylib" -type f -exec codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; \
551+
find $$(PYTHON_FRAMEWORK-macosx) -name "*.dylib" -type f -exec codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; \
539552
2>&1 | tee -a $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
540-
find install/macOS/macosx/python-3.13.0a1/Python.framework -name "*.so" -type f -exec codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; \
553+
find $$(PYTHON_FRAMEWORK-macosx) -name "*.so" -type f -exec codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; \
541554
2>&1 | tee -a $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
542555
codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f $$(PYTHON_FRAMEWORK-macosx) \
543556
2>&1 | tee -a $$(PYTHON_INSTALL-macosx)/python-$(os).codesign.log
@@ -588,6 +601,7 @@ $$(PYTHON_XCFRAMEWORK-$(os))/Info.plist: \
588601
echo "libFFI: $(LIBFFI_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
589602
echo "BZip2: $(BZIP2_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
590603
echo "OpenSSL: $(OPENSSL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
604+
echo "mpdecimal: $(MPDECIMAL_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
591605
echo "XZ: $(XZ_VERSION)" >> support/$(PYTHON_VER)/$(os)/VERSIONS
592606

593607
dist/Python-$(PYTHON_VER)-$(os)-support.$(BUILD_NUMBER).tar.gz: \

README.rst

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,43 @@ into a macOS, iOS, tvOS or watchOS project.
88
Other Python versions are available by cloning other branches of the main
99
repository:
1010

11-
* `Python 3.8 <https://github.com/beeware/Python-Apple-support/tree/3.8>`__
1211
* `Python 3.9 <https://github.com/beeware/Python-Apple-support/tree/3.9>`__
1312
* `Python 3.10 <https://github.com/beeware/Python-Apple-support/tree/3.10>`__
1413
* `Python 3.11 <https://github.com/beeware/Python-Apple-support/tree/3.11>`__
1514
* `Python 3.12 <https://github.com/beeware/Python-Apple-support/tree/3.12>`__
15+
* `Python 3.13 <https://github.com/beeware/Python-Apple-support/tree/3.13>`__
1616

17-
It works by downloading, patching, and building a fat binary of Python and selected
18-
pre-requisites, and packaging them as static libraries that can be incorporated into an
19-
XCode project. The binary modules in the Python standard library are statically
20-
compiled, but are distributed as objects that can be dynamically loaded at runtime.
17+
It works by downloading, patching, and building a fat binary of Python and
18+
selected pre-requisites, and packaging them as frameworks that can be
19+
incorporated into an XCode project. The binary modules in the Python standard
20+
library are distributed as binaries that can be dynamically loaded at runtime.
2121

2222
The macOS package is a re-bundling of the official macOS binary, modified so that
23-
it is relocatable.
24-
25-
The iOS, tvOS and watchOS packages are compiled by this project. They expose
26-
*almost* all the modules in the Python standard library except for:
27-
28-
* ``curses``
29-
* ``dbm.gnu``
30-
* ``grp``
31-
* ``multiprocessing``
32-
* ``nis`` (Deprecated by PEP594)
33-
* ``ossaudiodev`` (Deprecated by PEP594)
34-
* ``posixshmem``
35-
* ``posixsubprocess``
36-
* ``readline``
37-
* ``spwd`` (Deprecated by PEP594)
38-
* ``syslog``
39-
* ``tkinter``
23+
it is relocatable, with the IDLE, Tkinter and turtle packages removed.
24+
25+
The iOS, tvOS and watchOS packages compiled by this project use the official
26+
`PEP 730 <https://peps.python.org/pep-0730/>`__ code that is part of Python 3.13
27+
to provide iOS support; the relevant patches have been backported to 3.9-3.12.
28+
Additional patches have been applied to add tvOS and watchOS support.
4029

4130
The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV
42-
devices; and arm64_32 for watchOS. It also supports device simulators on both
43-
x86_64 and M1 hardware. This should enable the code to run on:
31+
devices; and arm64_32 for watchOS devices. It also supports device simulators on
32+
both x86_64 and M1 hardware. This should enable the code to run on:
4433

4534
* macOS 11 (Big Sur) or later, on:
4635
* MacBook (including MacBooks using Apple Silicon)
4736
* iMac (including iMacs using Apple Silicon)
4837
* Mac Mini (including Apple Silicon Mac minis)
4938
* Mac Studio (all models)
5039
* Mac Pro (all models)
51-
* iOS 12.0 or later, on:
40+
* iOS 13.0 or later, on:
5241
* iPhone (6s or later)
5342
* iPad (5th gen or later)
5443
* iPad Air (all models)
5544
* iPad Mini (2 or later)
5645
* iPad Pro (all models)
5746
* iPod Touch (7th gen or later)
58-
* tvOS 9.0 or later, on:
47+
* tvOS 12.0 or later, on:
5948
* Apple TV (4th gen or later)
6049
* watchOS 4.0 or later, on:
6150
* Apple Watch (4th gen or later)
@@ -121,18 +110,11 @@ see the `usage guide <./USAGE.md>`__
121110
Building binary wheels
122111
----------------------
123112

124-
When building binary wheels, you may need to use the libraries built by this
125-
project as inputs (e.g., the `cffi` module uses `libffi`). To support this, this
126-
project is able to package these dependencies as "wheels" that can be added to
127-
the ``dist`` directory of the `Mobile Forge
128-
project <https://github.com/beeware/mobile-forge>`__.
129-
130-
To build these wheels, run:
131-
132-
* ``make wheels`` to make all wheels for all mobile platforms
133-
* ``make wheels-iOS`` to build all the iOS wheels
134-
* ``make wheels-tvOS`` to build all the tvOS wheels
135-
* ``make wheels-watchOS`` to build all the watchOS wheels
113+
This project packages the Python standard library, but does not address building
114+
binary wheels. Binary wheels for macOS can be obtained from PyPI. `Mobile Forge
115+
<https://github.com/beeware/mobile-forge>`__ is a project that provides the
116+
tooling to build build binary wheels for iOS (and potentially for tvOS and
117+
watchOS, although that hasn't been tested).
136118

137119
Historical support
138120
------------------
@@ -145,3 +127,4 @@ maintained:
145127
* `Python 3.5 <https://github.com/beeware/Python-Apple-support/tree/3.5>`__ (EOL February 2021)
146128
* `Python 3.6 <https://github.com/beeware/Python-Apple-support/tree/3.6>`__ (EOL December 2021)
147129
* `Python 3.7 <https://github.com/beeware/Python-Apple-support/tree/3.7>`__ (EOL September 2022)
130+
* `Python 3.8 <https://github.com/beeware/Python-Apple-support/tree/3.8>`__ (EOL October 2024)

0 commit comments

Comments
 (0)