Utilities¶
Platform detection and Android context helpers. These are the lowest layer the rest of the package builds on; you usually only need them if you are writing your own native handler or interop code.
Platform detection and shared helpers.
This module is imported early by most other modules, so it avoids
importing platform-specific packages at module level. The detection
results are cached the first time
IS_ANDROID,
IS_IOS, and
IS_WEB are read.
Attributes:
| Name | Type | Description |
|---|---|---|
IS_ANDROID |
bool
|
|
IS_IOS |
bool
|
|
IS_WEB |
bool
|
|
Functions:
| Name | Description |
|---|---|
overlay_root |
The dev-client overlay directory configured for this process, if any. |
IS_ANDROID
module-attribute
¶
IS_ANDROID: bool = _get_is_android()
True when running inside an Android process.
The flag is computed once at import time, from sys.platform ==
"android" or a successful import of Chaquopy's java module.
IS_IOS
module-attribute
¶
IS_IOS: bool = _get_is_ios()
True when running inside an iOS app bundle.
The flag is computed once at import time, from sys.platform ==
"ios" or the explicit PN_PLATFORM=ios override.
IS_WEB
module-attribute
¶
IS_WEB: bool = _get_is_web()
True when running the browser preview.
Set by pn preview / pn start via PN_PLATFORM=web. Mutually
exclusive with IS_ANDROID / IS_IOS. Off-device unit tests leave
this False and inject a fake backend instead.
IS_NATIVE
module-attribute
¶
IS_NATIVE: bool = IS_ANDROID or IS_IOS or IS_WEB
True whenever the reconciler commits through the bridge.
All three of iOS, Android, and the browser preview render through a bridge transport; only headless tests have no native side at all.
OVERLAY_ENV
module-attribute
¶
Environment variable naming the dev-client source overlay, when one is configured.
overlay_root
¶
The dev-client overlay directory configured for this process, if any.
Debug builds set it through pythonnative.hot_reload.configure_dev_environment;
release builds never do, so this is None there. It lives here rather
than in hot_reload because runtime code (asset resolution) asks for it,
and release bundles omit the development modules.
Next steps¶
- Read about the broader runtime in Architecture.