1
1
Python Apple Support
2
2
====================
3
3
4
- **This repository branch builds a packaged version of Python 3.9.12 **.
4
+ **This repository branch builds a packaged version of Python 3.9.14 **.
5
5
Other Python versions are available by cloning other branches of the main
6
6
repository.
7
7
@@ -10,9 +10,11 @@ into a macOS, iOS, tvOS or watchOS project.
10
10
11
11
It works by downloading, patching, and building a fat binary of Python and
12
12
selected pre-requisites, and packaging them as static libraries that can be
13
- incorporated into an XCode project.
13
+ incorporated into an XCode project. The binary modules in the Python standard
14
+ library are statically compiled, but are distribted as ``.so `` objects that
15
+ can be dynamically loaded at runtime.
14
16
15
- It exposed *almost * all the modules in the Python standard library except for:
17
+ It exposes *almost * all the modules in the Python standard library except for:
16
18
* dbm.gnu
17
19
* tkinter
18
20
* readline
@@ -23,7 +25,11 @@ It exposed *almost* all the modules in the Python standard library except for:
23
25
The following standard library modules are available on macOS, but not the other
24
26
Apple platforms:
25
27
* curses
28
+ * grp
29
+ * multiprocessing
26
30
* posixshmem
31
+ * posixsubprocess
32
+ * syslog
27
33
28
34
The binaries support x86_64 and arm64 for macOS; arm64 for iOS and appleTV
29
35
devices; and arm64_32 for watchOS. It also supports device simulators on both
@@ -35,7 +41,7 @@ x86_64 and M1 hardware. This should enable the code to run on:
35
41
* Mac Mini (including M1 Apple Silicon Mac minis)
36
42
* Mac Studio (all models)
37
43
* Mac Pro (all models)
38
- * iOS 13 .0 or later, on:
44
+ * iOS 12 .0 or later, on:
39
45
* iPhone (6s or later)
40
46
* iPad (5th gen or later)
41
47
* iPad Air (all models)
@@ -48,6 +54,11 @@ x86_64 and M1 hardware. This should enable the code to run on:
48
54
Quickstart
49
55
----------
50
56
57
+ The easist way to use these packages is by creating a project with `Briefcase
58
+ <https://github.com/beeware/briefcase> `__. Briefcase will download pre-compiled
59
+ versions of these support packages, and add them to an XCode project (or
60
+ pre-build stub application, in the case of macOS).
61
+
51
62
Pre-built versions of the frameworks can be downloaded `for macOS `_, `for
52
63
iOS `_, `for tvOS `_, and `for watchOS `_, and added to your project.
53
64
@@ -66,10 +77,76 @@ This should:
66
77
2. Patch them as required for compatibility with the selected OS
67
78
3. Build the packages as XCode-compatible XCFrameworks.
68
79
69
- The build products will be in the `build ` directory; the compiled frameworks
70
- will be in the `dist ` directory.
80
+ The resulting support packages will be packaged as a ``.tar.gz `` file
81
+ in the ``dist `` folder.
82
+
83
+ Each support package contains:
84
+
85
+ * ``VERSIONS ``, a text file describing the specific versions of code used to
86
+ build the support package;
87
+ * ``Python.xcframework ``, a multi-architecture build of libPython3.9.a
88
+ * ``python-stdlib ``, the code and binary modules comprising the Python standard
89
+ library. On iOS, tvOS and watchOS, there are 2 copies of every binary module -
90
+ one for physical devices, and one for the simulator. The simulator binaries
91
+ are "fat", containing code for both x86_64 and arm64.
92
+
93
+ Non-macOS platforms also contain a ``platform-site `` folder. This contains a
94
+ site customization script that can be used to make your local Python install
95
+ look like it is an on-device install. This is needed because when you run
96
+ ``pip `` you'll be on a macOS machine; if ``pip `` tries to install a binary
97
+ package, it will install a macOS binary wheel (which won't work on
98
+ iOS/tvOS/watchOS). However, if you add the ``platform-site `` folder to your
99
+ ``PYTHONPATH `` when invoking pip, the site customization will make your Python
100
+ install return ``platform `` and ``sysconfig `` responses consistent with
101
+ on-device behavior, which will cause ``pip `` to install platform-appropriate
102
+ packages.
103
+
104
+ To add a support package to your own Xcode project:
105
+
106
+ 1. Drag ``Python.xcframework `` and ``python-stdlib `` into your Xcode project
107
+ tree.
108
+ 2. Ensure that these two objects are added to any targets that need to use
109
+ them;
110
+ 3. Add a custom build phase to purge any binary modules for the platform you are
111
+ *not * targetting; and
112
+ 4. Add a custom build phase to sign any of the binary modules in your app.
113
+ 5. Add CPython API code to your app to create an instance of the Python
114
+ interpreter.
115
+
116
+ For examples of the scripts needed for steps 3 and 4, and the code needed for
117
+ step 5, compare with a project generated with Briefcase.
118
+
119
+ On macOS, you must also either:
120
+ 1. Enable the "Disable Library Validation" entitlement (found on the "Signing
121
+ & Capabilities" tab in XCode); or
122
+ 2. Sign your app with a Development or Distribution certificate. This will
123
+ require a paid Apple Developer subscription.
124
+
125
+ It is not possible to use an ad-hoc signing certificate with the "Disable
126
+ Library Validation" entitlement disabled.
127
+
128
+ On iOS/tvOS/watchOS, you can use the default developer certificate for deploying
129
+ to a device simulator. However, to deploy to a physical device (including your
130
+ own), you will require a Development or Distribution certificate, which requires
131
+ a paid Apple Developer subscription.
132
+
133
+ Building binary wheels
134
+ ----------------------
135
+
136
+ When building binary wheels, you may need to use the libraries built by this
137
+ project as inputs (e.g., the `cffi ` module uses `libffi `). To support this, this
138
+ project is able to package these dependencies as "wheels" that can be added to
139
+ the `server/pypi/dist ` directory of the [binary dependency builder
140
+ project](https://github.com/freakboy3742/chaquopy).
141
+
142
+ To build these wheels, run:
143
+
144
+ * `make wheels ` to make all wheels for all mobile platforms
145
+ * `make wheels-iOS ` to build all the iOS wheels
146
+ * `make wheels-tvOS ` to build all the tvOS wheels
147
+ * `make wheels-watchOS ` to build all the watchOS wheels
71
148
72
- .. _for macOS : https://briefcase-support.org /python?platform= macOS&version= 3.9
73
- .. _for iOS : https://briefcase-support.org /python?platform= iOS&version= 3.9
74
- .. _for tvOS : https://briefcase-support.org /python?platform= tvOS&version= 3.9
75
- .. _for watchOS : https://briefcase-support.org /python?platform= watchOS&version= 3.9
149
+ .. _for macOS : https://briefcase-support.s3.amazonaws.com /python/3.9/ macOS/Python- 3.9-macOS-support.b8.tar.gz
150
+ .. _for iOS : https://briefcase-support.s3.amazonaws.com /python/3.9/ iOS/Python- 3.9-iOS-support.b8.tar.gz
151
+ .. _for tvOS : https://briefcase-support.s3.amazonaws.com /python/3.9/ tvOS/Python- 3.9-tvOS-support.b8.tar.gz
152
+ .. _for watchOS : https://briefcase-support.s3.amazonaws.com /python/3.9/ watchOS/Python- 3.9-watchOS-support.b8.tar.gz
0 commit comments