diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e628e24..070bfe2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-2022] + os: [ubuntu-22.04, windows-2022, macos-15] steps: - uses: actions/checkout@v4 @@ -23,7 +23,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.x' - architecture: 'x64' + architecture: ${{ runner.os == 'macOS' && 'arm64' || 'x64' }} - name: Compile wrapper on Windows if: startsWith(runner.os, 'Windows') @@ -34,13 +34,31 @@ jobs: cmake --build . --config Release cd .. - - name: Compile wrapper on Linux / macOS - if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') + - name: Compile wrapper on Linux + if: runner.os == 'Linux' run: | docker build -f DockerFile -t pythonfmu3-wrapper --target build . + - name: Compile wrapper on macOS (Apple Silicon and Intel) + if: runner.os == 'macOS' + run: | + # One runner builds both architectures: arm64 natively, x86_64 by cross-compiling. + # CMake puts each in its FMI platform folder (aarch64-darwin, x86_64-darwin). + for arch in arm64 x86_64; do + cmake -S pythonfmu3/pythonfmu-export -B build-$arch -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_ARCHITECTURES=$arch -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 + cmake --build build-$arch --config Release + done + for platform in aarch64-darwin x86_64-darwin; do + for lib in libpythonfmu-export.dylib libpythonfmu-backend.dylib; do + test -f pythonfmu3/resources/binaries/$platform/$lib || { echo "missing $platform/$lib"; exit 1; } + done + done + lipo -archs pythonfmu3/resources/binaries/aarch64-darwin/libpythonfmu-export.dylib + lipo -archs pythonfmu3/resources/binaries/x86_64-darwin/libpythonfmu-export.dylib + - name: Create container and copy out artifact - if : startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') + if: runner.os == 'Linux' run: | docker create --name extract pythonfmu3-wrapper docker cp extract:/io/pythonfmu3/resources $GITHUB_WORKSPACE/pythonfmu3 @@ -76,6 +94,18 @@ jobs: python -m pip install build python -m build + - name: Check the wheel has every platform's binaries + run: | + python - <<'PY' + import glob, zipfile + wheel = glob.glob("dist/*.whl")[0] + names = zipfile.ZipFile(wheel).namelist() + expected = ["x86_64-linux", "x86_64-windows", "aarch64-darwin", "x86_64-darwin"] + missing = [p for p in expected if not any(n.startswith(f"pythonfmu3/resources/binaries/{p}/") for n in names)] + print(wheel, "missing:", missing or "none") + raise SystemExit(1 if missing else 0) + PY + - name: Archive production artifacts uses: actions/upload-artifact@v4 with: @@ -88,8 +118,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04, windows-2022] - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14'] + # Every supported Python on Linux; the oldest and newest on Windows and macOS. + os: [ubuntu-22.04] + python-version: ['3.11', '3.12', '3.13', '3.14', '3.15'] + include: + - {os: windows-2022, python-version: '3.11'} + - {os: windows-2022, python-version: '3.15'} + - {os: macos-15, python-version: '3.11'} + - {os: macos-15, python-version: '3.15'} timeout-minutes: 15 steps: @@ -99,7 +135,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - architecture: 'x64' + architecture: ${{ runner.os == 'macOS' && 'arm64' || 'x64' }} - name: Download python package uses: actions/download-artifact@v4 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0ca1e21..cd8e272 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-2022] + os: [ubuntu-22.04, windows-2022, macos-15] steps: - uses: actions/checkout@v4 @@ -18,7 +18,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: '3.x' - architecture: 'x64' + architecture: ${{ runner.os == 'macOS' && 'arm64' || 'x64' }} - name: Compile wrapper on Windows if: startsWith(runner.os, 'Windows') run: | @@ -27,13 +27,31 @@ jobs: cmake $Env:github_workspace/pythonfmu3/pythonfmu-export -DCMAKE_BUILD_TYPE=Release -A x64 cmake --build . --config Release cd .. - - name: Compile wrapper on Linux / macOS - if: startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') + - name: Compile wrapper on Linux + if: runner.os == 'Linux' run: | docker build -f DockerFile -t pythonfmu3-wrapper --target build . + - name: Compile wrapper on macOS (Apple Silicon and Intel) + if: runner.os == 'macOS' + run: | + # One runner builds both architectures: arm64 natively, x86_64 by cross-compiling. + # CMake puts each in its FMI platform folder (aarch64-darwin, x86_64-darwin). + for arch in arm64 x86_64; do + cmake -S pythonfmu3/pythonfmu-export -B build-$arch -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_OSX_ARCHITECTURES=$arch -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 + cmake --build build-$arch --config Release + done + for platform in aarch64-darwin x86_64-darwin; do + for lib in libpythonfmu-export.dylib libpythonfmu-backend.dylib; do + test -f pythonfmu3/resources/binaries/$platform/$lib || { echo "missing $platform/$lib"; exit 1; } + done + done + lipo -archs pythonfmu3/resources/binaries/aarch64-darwin/libpythonfmu-export.dylib + lipo -archs pythonfmu3/resources/binaries/x86_64-darwin/libpythonfmu-export.dylib + - name: Create container and copy out artifact - if : startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') + if: runner.os == 'Linux' run: | docker create --name extract pythonfmu3-wrapper docker cp extract:/io/pythonfmu3/resources $GITHUB_WORKSPACE/pythonfmu3 @@ -69,4 +87,13 @@ jobs: TWINE_PASSWORD: ${{ secrets.PYPI_PYTHONFMU_API_TOKEN }} run: | python -m build + python - <<'PY' + import glob, zipfile + wheel = glob.glob("dist/*.whl")[0] + names = zipfile.ZipFile(wheel).namelist() + expected = ["x86_64-linux", "x86_64-windows", "aarch64-darwin", "x86_64-darwin"] + missing = [p for p in expected if not any(n.startswith(f"pythonfmu3/resources/binaries/{p}/") for n in names)] + print(wheel, "missing binaries:", missing or "none") + raise SystemExit(1 if missing else 0) + PY twine upload dist/* diff --git a/docs/changelog.md b/docs/changelog.md index 315e524..add1d6d 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,20 +1,33 @@ # Changelog -## 1.2.0 (unreleased) +## 1.3.0 (unreleased) ### Added -- **MCP server for AI agents** (`pythonfmu3 mcp`): Claude, GitHub Copilot in VS Code, - Cursor and other MCP clients can write, check, simulate and build FMUs, using the same - checks and simulators as the Studio. Install with `pip install "pythonfmu3[mcp]"` - (Python 3.10+). See [AI agents (MCP)](mcp.md). - **Jupyter support** (`%load_ext pythonfmu3`): the `%%fmu` cell magic saves, checks and displays a model; `simulate()` returns pandas DataFrames; `build()` builds the FMU; and `pythonfmu3.notebook.FMU` inspects and simulates any FMU. Install with `pip install "pythonfmu3[notebook]"`. See [Jupyter notebooks](notebooks.md) and `examples/notebooks/getting_started.ipynb`. +- **macOS binaries:** the PyPI packages now include the native library for Apple Silicon + (`aarch64-darwin`) and Intel Macs (`x86_64-darwin`), so FMUs build on macOS without + compiling anything. CI also runs the tests on macOS. - `llms.txt` and `llms-full.txt` on the documentation site, so AI assistants can learn the PythonFMU3 API and its rules. +### Changed +- Clearer documentation: a variables guide (causality and variability), what the importer + calls in your class, build options, per-platform installation, and dependencies. +- CI tests every supported Python version (3.11 to 3.15) on Linux, and the oldest and + newest on Windows and macOS. + +## 1.2.0 (2026-11-16) + +### Added +- **MCP server for AI agents** (`pythonfmu3 mcp`): Claude, GitHub Copilot in VS Code, + Cursor and other MCP clients can write, check, simulate and build FMUs, using the same + checks and simulators as the Studio. Install with `pip install "pythonfmu3[mcp]"` + (Python 3.10+). See [AI agents (MCP)](mcp.md). + ## 1.1.0 (2026-11-14) ### Added diff --git a/docs/install.md b/docs/install.md index e539a76..2af2e5f 100644 --- a/docs/install.md +++ b/docs/install.md @@ -49,7 +49,7 @@ this order: `export PYTHONFMU_PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.12.so.1.0`; 2. the library of the Python that built the FMU (recorded in `resources/pythonfmu_libpython.txt`); -3. standard library names for Python 3.8 to 3.14 (and the usual Homebrew and +3. standard library names for Python 3.8 to 3.20, newest first (and the usual Homebrew and python.org framework locations on macOS). If none can be loaded, instantiation fails with a message listing the paths tried. diff --git a/pyproject.toml b/pyproject.toml index 1ff0587..2395cd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", + "Programming Language :: Python :: 3.15", "Topic :: Scientific/Engineering", ] dependencies = [] diff --git a/pythonfmu3/_version.py b/pythonfmu3/_version.py index c68196d..67bc602 100644 --- a/pythonfmu3/_version.py +++ b/pythonfmu3/_version.py @@ -1 +1 @@ -__version__ = "1.2.0" +__version__ = "1.3.0" diff --git a/pythonfmu3/pythonfmu-export/src/shim/shim_loader.cpp b/pythonfmu3/pythonfmu-export/src/shim/shim_loader.cpp index ab09d26..c1d848c 100644 --- a/pythonfmu3/pythonfmu-export/src/shim/shim_loader.cpp +++ b/pythonfmu3/pythonfmu-export/src/shim/shim_loader.cpp @@ -15,7 +15,7 @@ // - the PYTHONFMU_PYTHON_LIBRARY environment variable (a full path), // - resources/pythonfmu_libpython.txt (written by the builder: the library of the // Python that built the FMU, one candidate path per line), -// - common library names for Python 3.8 - 3.14. +// - common library names for Python 3.8 - 3.20 (newest first). #include "shim/shim_loader.hpp" @@ -83,7 +83,7 @@ std::vector libpythonCandidates(const std::string& resources) if (!line.empty()) candidates.push_back(line); } } - for (int minor = 14; minor >= 8; --minor) { + for (int minor = 20; minor >= 8; --minor) { const std::string v = "3." + std::to_string(minor); #ifdef __APPLE__ candidates.push_back("libpython" + v + ".dylib");