beeware / Python-Apple-support

A meta-package for building a version of Python that can be embedded into a macOS, iOS, tvOS or watchOS project.
MIT License
1.08k stars 155 forks source link

Python Apple Support

This is a meta-package for building a version of Python that can be embedded into a macOS, iOS, tvOS or watchOS project.

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

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. The binary modules in the Python standard library are statically compiled, but are distributed as objects that can be dynamically loaded at runtime.

It exposes 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:

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 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 from the Github releases page <https://github.com/beeware/Python-Apple-support/releases>__ and added to your project.

Alternatively, to build the frameworks on your own, download/clone this repository, and then in the root directory, and run:

This should:

  1. Download the original source packages
  2. Patch them as required for compatibility with the selected OS
  3. Build the packages as Xcode-compatible XCFrameworks.

The resulting support packages will be packaged as a .tar.gz file in the dist folder.

Each support package contains:

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

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 dist directory of the Mobile Forge project <https://github.com/beeware/mobile-forge>__.

To build these wheels, run:

Historical support

The following versions were supported in the past, but are no longer maintained: