Skip to content

build: self-contained pip-installable Python wheel - #9

Merged
leonardoaraujosantos merged 1 commit into
mainfrom
feat/python-wheel
Jul 5, 2026
Merged

leonardoaraujosantos merged 1 commit into
mainfrom
feat/python-wheel

Conversation

@leonardoaraujosantos

Copy link
Copy Markdown
Contributor

Summary

Closes the last Tier-1 adoption item: pip install ./bindings/python now builds and bundles the native C ABI, so import cyberfluids works with no separate manual C++ build.

How

  • The binding switches to a scikit-build-core backend that drives the repo-root CMake build during pip install / pip wheel.
  • A new CYBERFLUIDS_PYTHON_WHEEL CMake path:
    • forces the pinned FetchContent NumPP built static + PIC and links it into libcyberfluids_c → a single self-contained .so with no external libnumpp dependency;
    • links libtbb with a DT_NEEDED entry on Linux (--no-as-needed);
    • installs the library into the cyberfluids package via its own python install component, so the fetched NumPP's own install rules stay out of the wheel.
  • For a wheel build, find_package(NumPP) is skipped so an installed shared NumPP under .deps can't break self-containment.
  • __init__.py loads the bundled library from the installed package first (build-tree fallback and $CYBERFLUIDS_LIBRARY override retained).
  • Adds bindings/python/README.md (PyPI long description).

Verification (clean venv)

pip install ./bindings/python        # compiles C ABI, fetches + static-links NumPP
python -c "import cyberfluids ..."    # from an arbitrary dir
# → version 0.0.1; loads .so from site-packages/cyberfluids/
# → 2D cavity  shape (48,48,2)  max|u|=0.0896
# → 3D tunnel  shape (48,24,24,3) max|u|=0.0629

ldd on the bundled .so: no libnumpp, no missing deps (only system libtbb/libstdc++). The 3 local python_* ctest failures remain the known Anaconda libstdc++ shadow (worked around here with LD_PRELOAD); CI's system Python is unaffected. Normal (non-wheel) build + all native tests unaffected.

Docs/spec

build-and-packaging spec gains a "self-contained Python wheel" requirement (+ scenarios); getting-started.md, roadmap.md, and CHANGELOG.md updated. openspec validate --all --strict → 14/14.

Follow-up (not in scope)

Publishing a manylinux wheel to PyPI (bundling libtbb/libstdc++ via auditwheel) is the remaining step for pip install cyberfluids from the index — tracked on the roadmap.

`pip install ./bindings/python` now builds and bundles the native C ABI — no
separate manual C++ build. Closes the last Tier-1 adoption item.

- Switch the binding to a scikit-build-core backend that drives the repo-root
  CMake build during pip install/wheel.
- New CYBERFLUIDS_PYTHON_WHEEL CMake path: forces the pinned FetchContent NumPP
  built static + PIC, links it into libcyberfluids_c, and links libtbb with a
  DT_NEEDED entry on Linux. The result is a single self-contained shared library
  (no external libnumpp runtime dependency) installed into the `cyberfluids`
  package via its own `python` install component (so the fetched NumPP's own
  install rules stay out of the wheel).
- For the wheel build, skip find_package(NumPP) so an installed *shared* NumPP
  under .deps can't sneak in and break self-containment.
- __init__.py loads the bundled library from the installed package first, keeping
  the build-tree fallback for in-repo development and the $CYBERFLUIDS_LIBRARY
  override.
- Add bindings/python/README.md (PyPI long description) with install + usage.

Verified in a clean venv: `pip install ./bindings/python` compiles the C ABI,
`import cyberfluids` loads the bundled .so from site-packages, and both a 2D
cavity and a 3D wind tunnel run and return NumPy fields. `ldd` confirms no
libnumpp dependency. Normal (non-wheel) build + native tests unaffected.

Docs/spec kept in sync: build-and-packaging spec gains a "self-contained Python
wheel" requirement; getting-started, roadmap, and CHANGELOG updated.
openspec validate --all --strict passes (14/14).
@leonardoaraujosantos
leonardoaraujosantos merged commit 0f41a64 into main Jul 5, 2026
3 checks passed
@leonardoaraujosantos
leonardoaraujosantos deleted the feat/python-wheel branch July 5, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant