MobDev.PythonAppleSupport (mob_dev v0.5.2)

Copy Markdown View Source

Downloads and caches BeeWare's Python-Apple-support bundle so iOS builds can embed CPython.

Mirrors the MobDev.OtpDownloader pattern: hashed URL + cached download at ~/.mob/cache/python-apple-support-<version>/, validated against the expected Python.xcframework layout. Reused across projects.

Used by MobDev.NativeBuild whenever the user's project depends on :pythonx — the build templates source PYTHON_APPLE_SUPPORT from extracted_dir/0 and bundle the framework + stdlib + lib-dynload inside the .app.

Scope

Only the bare CPython runtime + standard library + standard arch-specific C extensions ship via this module. Third-party wheels (cryptography, RNS, numpy, …) are out of scope; users who need those should produce their own wheels with BeeWare's mobile-forge and drop them into their project. See guides/python_embedding.md.

Summary

Functions

URL the bundle is fetched from.

Ensures the BeeWare Python-Apple-support bundle is cached and extracted. Returns {:ok, extracted_dir} or {:error, reason}.

Returns the cached extraction directory path. May not exist if ensure/0 hasn't been called.

Path to Python.framework inside the given extracted bundle for the named platform slice.

Path to the arch-specific C-extension dir (_ctypes.so, _ssl.so, …). These live OUTSIDE the shared stdlib because they're per-slice.

Pinned Python version (3.13, 3.14, …).

Pinned BeeWare release tag.

Path to the shared (slice-independent) Python standard library directory. This is the pure-Python os.py, urllib/, etc. layout that goes under PYTHONHOME/lib/python3.13/.

Tarball file name (used for caching the downloaded artifact).

Validates that the extracted bundle has the Python.xcframework layout this module expects (both device and simulator slices, plus shared stdlib).

Functions

download_url()

@spec download_url() :: String.t()

URL the bundle is fetched from.

ensure()

@spec ensure() :: {:ok, String.t()} | {:error, term()}

Ensures the BeeWare Python-Apple-support bundle is cached and extracted. Returns {:ok, extracted_dir} or {:error, reason}.

extracted_dir()

@spec extracted_dir() :: String.t()

Returns the cached extraction directory path. May not exist if ensure/0 hasn't been called.

framework_path(dir, atom)

@spec framework_path(String.t(), :ios_device | :ios_simulator) :: String.t()

Path to Python.framework inside the given extracted bundle for the named platform slice.

slice is one of :ios_device (ios-arm64/) or :ios_simulator (ios-arm64_x86_64-simulator/).

lib_dynload_path(dir, atom)

@spec lib_dynload_path(String.t(), :ios_device | :ios_simulator) :: String.t()

Path to the arch-specific C-extension dir (_ctypes.so, _ssl.so, …). These live OUTSIDE the shared stdlib because they're per-slice.

python_version()

@spec python_version() :: String.t()

Pinned Python version (3.13, 3.14, …).

release_tag()

@spec release_tag() :: String.t()

Pinned BeeWare release tag.

stdlib_path(dir)

@spec stdlib_path(String.t()) :: String.t()

Path to the shared (slice-independent) Python standard library directory. This is the pure-Python os.py, urllib/, etc. layout that goes under PYTHONHOME/lib/python3.13/.

tarball_name()

@spec tarball_name() :: String.t()

Tarball file name (used for caching the downloaded artifact).

valid_dir?(dir)

@spec valid_dir?(String.t()) :: boolean()

Validates that the extracted bundle has the Python.xcframework layout this module expects (both device and simulator slices, plus shared stdlib).

Public to enable testing (per AGENTS.md convention) and to let MobDev.NativeBuild cheaply detect a partial cache.