Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
3730a2a
Improved subprocess handling.
freakboy3742 May 15, 2022
ce0ed90
Merge branch 'dev' into 3.10
freakboy3742 May 19, 2022
d305f40
Merge branch 'dev' into 3.10
freakboy3742 May 19, 2022
77de18c
Merge branch 'dev' into 3.10
freakboy3742 May 19, 2022
5a4d6e7
Merge branch 'dev' into 3.10
freakboy3742 May 30, 2022
d7d970e
Merge branch 'dev' into 3.10
freakboy3742 May 31, 2022
a3c2838
Merge branch 'dev' into 3.10
freakboy3742 May 31, 2022
8a074e1
Merge branch 'dev' into 3.10
freakboy3742 Jul 3, 2022
9548669
Update patch to 3.11.0b5.
freakboy3742 Jul 28, 2022
eb45497
Fixes #149 -- Isolate the path to the bare minimum. This removes the …
freakboy3742 Jul 29, 2022
2aea01c
Improve download related targets
afh Aug 15, 2022
73ae260
Merge pull request #155 from afh/afh/improve-downloads
freakboy3742 Aug 15, 2022
9514d46
Use $$< instead of $$^
afh Aug 16, 2022
6d1511b
Change order of prerequisites
afh Aug 16, 2022
fac33f9
Fix libffi and xz download file extensions
afh Aug 16, 2022
17eb57d
Fix typo
afh Aug 16, 2022
0936e8f
Fix another typo
afh Aug 16, 2022
7485a16
Fix blankspace and newline at end of file
afh Aug 16, 2022
24ec0cd
Merge pull request #160 from afh/afh/fix-blankspace
freakboy3742 Aug 17, 2022
53a1ec2
Merge pull request #158 from afh/afh/fixup-improve-downloads
freakboy3742 Aug 17, 2022
5d97735
Minor patch cleanups.
freakboy3742 Jul 29, 2022
0a9ffe4
Revert to dynamic modules for macOS builds.
freakboy3742 Aug 2, 2022
99af12b
Build completing for iOS dynamic modules.
freakboy3742 Aug 5, 2022
6ad009a
Restructure build products to give better control over outputs.
freakboy3742 Aug 18, 2022
7eed1bb
Correct iOS naming of XZ library, and include a stub sysconfigdata mo…
freakboy3742 Aug 23, 2022
cd4ae50
Use lipo rather than libtool to merge binaries.
freakboy3742 Aug 23, 2022
d2607a0
platform.machine() doesn't work quite as expected on hardware.
freakboy3742 Aug 23, 2022
873a134
Switch to OpenSSL 3.
freakboy3742 Aug 26, 2022
5e2acc0
Updated README, including details on how to use the support packages.
freakboy3742 Aug 26, 2022
7e7b142
Additional tweaks picked up by testing third party binary wheels.
freakboy3742 Aug 31, 2022
4ecd795
Correct the handling of arm64_32 in watchOS headers.
freakboy3742 Aug 31, 2022
9250f70
Add a templated cross-platform sitecustomize.py to non-macOS support …
freakboy3742 Sep 1, 2022
4686008
Update patch to 3.11.0rc0, and xz-5.2.6.
freakboy3742 Sep 1, 2022
2f42105
Tweak the values returned by platform module.
freakboy3742 Sep 5, 2022
b1d9523
Merge branch 'dynamic-loading' into dynamic-loading-3.10
freakboy3742 Sep 6, 2022
e25db43
Correct the XZ patch for the 5.2.6 update.
freakboy3742 Sep 6, 2022
13d9af0
Merge branch 'dynamic-loading' into dynamic-loading-3.10
freakboy3742 Sep 6, 2022
59c518b
Clean up sysconfigdata shims.
freakboy3742 Sep 6, 2022
e791b31
Merge branch 'dynamic-loading' into dynamic-loading-3.10
freakboy3742 Sep 6, 2022
59f9bcb
Normalize the naming of the BZip2 merged library.
freakboy3742 Sep 6, 2022
d490808
Merge branch 'dynamic-loading' into dynamic-loading-3.10
freakboy3742 Sep 6, 2022
dba406c
Update patch to Python 3.10.6.
freakboy3742 Sep 6, 2022
4205763
Updated Python patch to remove vestigial parts.
freakboy3742 Sep 7, 2022
543d872
Merge branch 'dynamic-loading-3.10' into dynamic-loading-3.9
freakboy3742 Sep 6, 2022
857c819
Update patch for Python 3.9.13.
freakboy3742 Sep 7, 2022
7c57bbd
Update to Python 3.9.14, and remove vestigial patch pieces.
freakboy3742 Sep 7, 2022
df4921b
Remove the testbed project (now maintained as a standalone project)
freakboy3742 Sep 7, 2022
6201c2e
Update to Python 3.10.7, and remove vestigial patch pieces.
freakboy3742 Sep 7, 2022
f2f29bc
Merge branch 'dynamic-loading' into dynamic-loading-3.10
freakboy3742 Sep 7, 2022
b1f09e1
Merge branch 'dynamic-loading-3.10' into dynamic-loading-3.9
freakboy3742 Sep 7, 2022
92089b7
Add site patch to disable distutils.
freakboy3742 Sep 12, 2022
10fe3b6
Merge branch 'dynamic-loading' into dynamic-loading-3.9
freakboy3742 Sep 12, 2022
895e660
Add the ability to generate wheels for build dependencies.
freakboy3742 Sep 16, 2022
cff598c
Purge dynamic libraries from wheels.
freakboy3742 Sep 21, 2022
8d88e7e
Merge branch 'dynamic-loading' into dynamic-loading-3.9
freakboy3742 Sep 22, 2022
86b83b1
Remove briefcase-support.org from download URLs.
freakboy3742 Sep 22, 2022
b1a45a0
Merge branch 'dynamic-loading' into dynamic-loading-3.9
freakboy3742 Sep 22, 2022
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
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
*.swo
*.swp
src/*
.envrc
.vscode/
archive/*
build/*
downloads/*
diff/*
dist/*
.envrc
.vscode/
downloads/*
install/*
local/*
merge/*
src/*
support/*
wheels/*
*.dist-info
__pycache__
tests/testbed/macOS
Expand Down
1,199 changes: 735 additions & 464 deletions Makefile

Large diffs are not rendered by default.

97 changes: 87 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Python Apple Support
====================

**This repository branch builds a packaged version of Python 3.9.12**.
**This repository branch builds a packaged version of Python 3.9.14**.
Other Python versions are available by cloning other branches of the main
repository.

Expand All @@ -10,9 +10,11 @@ into a macOS, iOS, tvOS or watchOS project.

It works by downloading, patching, and building a fat binary of Python and
selected pre-requisites, and packaging them as static libraries that can be
incorporated into an XCode project.
incorporated into an XCode project. The binary modules in the Python standard
library are statically compiled, but are distribted as ``.so`` objects that
can be dynamically loaded at runtime.

It exposed *almost* all the modules in the Python standard library except for:
It exposes *almost* all the modules in the Python standard library except for:
* dbm.gnu
* tkinter
* readline
Expand All @@ -23,7 +25,11 @@ It exposed *almost* all the modules in the Python standard library except for:
The following standard library modules are available on macOS, but not the other
Apple platforms:
* curses
* grp
* multiprocessing
* posixshmem
* posixsubprocess
* syslog

The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV
devices; and arm64_32 for watchOS. It also supports device simulators on both
Expand All @@ -35,7 +41,7 @@ x86_64 and M1 hardware. This should enable the code to run on:
* Mac Mini (including M1 Apple Silicon Mac minis)
* Mac Studio (all models)
* Mac Pro (all models)
* iOS 13.0 or later, on:
* iOS 12.0 or later, on:
* iPhone (6s or later)
* iPad (5th gen or later)
* iPad Air (all models)
Expand All @@ -48,6 +54,11 @@ x86_64 and M1 hardware. This should enable the code to run on:
Quickstart
----------

The easist way to use these packages is by creating a project with `Briefcase
<https://github.com/beeware/briefcase>`__. Briefcase will download pre-compiled
versions of these support packages, and add them to an XCode project (or
pre-build stub application, in the case of macOS).

Pre-built versions of the frameworks can be downloaded `for macOS`_, `for
iOS`_, `for tvOS`_, and `for watchOS`_, and added to your project.

Expand All @@ -66,10 +77,76 @@ This should:
2. Patch them as required for compatibility with the selected OS
3. Build the packages as XCode-compatible XCFrameworks.

The build products will be in the `build` directory; the compiled frameworks
will be in the `dist` directory.
The resulting support packages will be packaged as a ``.tar.gz`` file
in the ``dist`` folder.

Each support package contains:

* ``VERSIONS``, a text file describing the specific versions of code used to
build the support package;
* ``Python.xcframework``, a multi-architecture build of libPython3.9.a
* ``python-stdlib``, the code and binary modules comprising the Python standard
library. On iOS, tvOS and watchOS, there are 2 copies of every binary module -
one for physical devices, and one for the simulator. The simulator binaries
are "fat", containing code for both x86_64 and arm64.

Non-macOS platforms also contain a ``platform-site`` folder. This contains a
site customization script that can be used to make your local Python install
look like it is an on-device install. This is needed because when you run
``pip`` you'll be on a macOS machine; 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.

To add a support package to your own Xcode project:

1. Drag ``Python.xcframework`` and ``python-stdlib`` into your Xcode project
tree.
2. Ensure that these two objects are added to any targets that need to use
them;
3. Add a custom build phase to purge any binary modules for the platform you are
*not* targetting; and
4. Add a custom build phase to sign any of the binary modules in your app.
5. Add CPython API code to your app to create an instance of the Python
interpreter.

For examples of the scripts needed for steps 3 and 4, and the code needed for
step 5, compare with a project generated with Briefcase.

On macOS, you must also either:
1. Enable the "Disable Library Validation" entitlement (found on the "Signing
& Capabilities" tab in XCode); or
2. Sign your app with a Development or Distribution certificate. This will
require a paid Apple Developer subscription.

It is not possible to use an ad-hoc signing certificate with the "Disable
Library Validation" entitlement disabled.

On iOS/tvOS/watchOS, you can use the default developer certificate for deploying
to a device simulator. However, to deploy to a physical device (including your
own), you will require a Development or Distribution certificate, which requires
a paid Apple Developer subscription.

Building binary wheels
----------------------

When building binary wheels, you may need to use the libraries built by this
project as inputs (e.g., the `cffi` module uses `libffi`). To support this, this
project is able to package these dependencies as "wheels" that can be added to
the `server/pypi/dist` directory of the [binary dependency builder
project](https://github.com/freakboy3742/chaquopy).

To build these wheels, run:

* `make wheels` to make all wheels for all mobile platforms
* `make wheels-iOS` to build all the iOS wheels
* `make wheels-tvOS` to build all the tvOS wheels
* `make wheels-watchOS` to build all the watchOS wheels

.. _for macOS: https://briefcase-support.org/python?platform=macOS&version=3.9
.. _for iOS: https://briefcase-support.org/python?platform=iOS&version=3.9
.. _for tvOS: https://briefcase-support.org/python?platform=tvOS&version=3.9
.. _for watchOS: https://briefcase-support.org/python?platform=watchOS&version=3.9
.. _for macOS: https://briefcase-support.s3.amazonaws.com/python/3.9/macOS/Python-3.9-macOS-support.b8.tar.gz
.. _for iOS: https://briefcase-support.s3.amazonaws.com/python/3.9/iOS/Python-3.9-iOS-support.b8.tar.gz
.. _for tvOS: https://briefcase-support.s3.amazonaws.com/python/3.9/tvOS/Python-3.9-tvOS-support.b8.tar.gz
.. _for watchOS: https://briefcase-support.s3.amazonaws.com/python/3.9/watchOS/Python-3.9-watchOS-support.b8.tar.gz
Loading