From bc9d8f00fc61d4b1a29b70ccc94c2290055ec5f6 Mon Sep 17 00:00:00 2001 From: milanofthe Date: Wed, 27 May 2026 11:05:58 +0200 Subject: [PATCH] Gate jsbsim behind sys_platform marker for Pyodide compatibility --- pyproject.toml | 6 +++++- src/pathsim_flight/__init__.py | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 4b67553..dcb7dc1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,11 @@ dependencies = [ "pathsim", "numpy>=1.15", "scipy>=1.2", - "jsbsim>=1.2.4" + # JSBSim ships native code that can't be installed in Pyodide. The + # marker resolves to a normal eager install on every real platform and + # is skipped on Emscripten so the pure-Python parts of the toolbox + # (`pathsim_flight.atmosphere`, `.utils`) still install in the browser. + "jsbsim>=1.2.4; sys_platform != 'emscripten'", ] [project.optional-dependencies] diff --git a/src/pathsim_flight/__init__.py b/src/pathsim_flight/__init__.py index 38f709c..193449d 100644 --- a/src/pathsim_flight/__init__.py +++ b/src/pathsim_flight/__init__.py @@ -12,7 +12,14 @@ __all__ = ["__version__"] -# For direct block import from main package -from .atmosphere import * -from .jsbsim import * -from .utils import * +# Pure-Python submodules — eager. +from .atmosphere import * # noqa: F401,F403 +from .utils import * # noqa: F401,F403 + +# `jsbsim` wraps the native JSBSim Python bindings, which can't load in +# Pyodide. Re-export the wrapper only when the import succeeds; on a normal +# pip install it loads eagerly. +try: + from .jsbsim import * # noqa: F401,F403 +except ImportError: + pass