Skip to content

Python

Install the binding and one runtime from PyPI. It needs Python 3.12 or later. The runtime holds the native library for your backend: maplibre-native-ffi-runtime-opengl, -metal, or -vulkan. Importing the binding fails unless exactly one runtime is installed.

Terminal window
pip install maplibre-native-ffi maplibre-native-ffi-runtime-vulkan

To choose the runtime by platform, give each one an environment marker:

pyproject.toml
[project]
dependencies = [
"maplibre-native-ffi",
"maplibre-native-ffi-runtime-metal; sys_platform == 'darwin'",
"maplibre-native-ffi-runtime-opengl; sys_platform != 'darwin'",
]

The runtimes above use MSVC on Windows. For MinGW, install maplibre-native-ffi-runtime-opengl-mingw or maplibre-native-ffi-runtime-vulkan-mingw instead.

Initialize the library once per process, before you create a runtime, with the calling thread’s JNI environment and an Android Context:

main.py
maplibre_native_ffi.api.init_android(jni_env, context)