Skip to content

fix: Replace custom build script with standard setuptools integration#23

Open
burdettadam wants to merge 14 commits intomainfrom
fix/python-build-system
Open

fix: Replace custom build script with standard setuptools integration#23
burdettadam wants to merge 14 commits intomainfrom
fix/python-build-system

Conversation

@burdettadam
Copy link
Contributor

  • Remove setuptools-rust dependency - UniFFI doesn't need it
  • Implement custom build commands that invoke cargo directly
  • Add cross-compilation support to match Python architecture
  • Automatically generate UniFFI bindings during pip install
  • Copy cdylib to package for ctypes loading

This makes the package easy to install via pip or Poetry without manual build steps. The build now works like standard Python packages with Rust extensions.

- Remove setuptools-rust dependency - UniFFI doesn't need it
- Implement custom build commands that invoke cargo directly
- Add cross-compilation support to match Python architecture
- Automatically generate UniFFI bindings during pip install
- Copy cdylib to package for ctypes loading

This makes the package easy to install via pip or Poetry without
manual build steps. The build now works like standard Python packages
with Rust extensions.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
The setup.py was incorrectly trying to cross-compile for macOS targets
(aarch64-apple-darwin) even when running inside Linux containers.
This caused Docker builds to fail.

Now only applies macOS-specific cross-compilation when platform.system()
== 'Darwin'. On Linux and other platforms, uses native Rust compilation.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
- Replace setuptools with maturin build backend
- Update CI/CD workflows to use maturin-action
- Build proper platform-tagged wheels (manylinux, universal2, win_amd64)
- Simplify build process - no custom scripts needed

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
Maturin requires module name without hyphens. Explicitly set module-name to isomdl_uniffi.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
UniFFI bindings are auto-generated by maturin, no need to specify python-source directory.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
UniFFI cannot inspect universal2 binaries, causing 'Invalid string data' error.
Build separate wheels for x86_64 and aarch64 instead.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
Signed-off-by: Adam Burdett <burdettadam@gmail.com>
Signed-off-by: Adam Burdett <burdettadam@gmail.com>
The python/isomdl_uniffi/ directory was entirely in .gitignore, which meant
the __init__.py file was not included in the wheel when built by GitHub Actions.

This caused the published wheels to be broken - they only contained the .so
library but not the Python bindings module that exports the Mdoc class and
other UniFFI-generated types.

Changes:
- Update .gitignore to only ignore generated files (isomdl_uniffi.py, *.so,
  *.dylib, *.dll) but not __init__.py
- Add python/isomdl_uniffi/__init__.py to git tracking

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
The wheel structure has both isomdl_uniffi.py (module) and isomdl_uniffi/ (package
 containing the .so file). Python prefers packages over modules, so the standard
import statement would find the empty package __init__.py instead of the bindings.

This fix uses importlib.util to explicitly load the .py file by path.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
The generated Python bindings look for the .so next to isomdl_uniffi.py
via os.path.dirname(__file__), but the wheel places it in a subdirectory.
Create a symlink (or copy) so the bindings can find the native library.

Signed-off-by: Adam Burdett <burdettadam@gmail.com>
@burdettadam burdettadam force-pushed the fix/python-build-system branch from aa0731f to 903cc26 Compare February 13, 2026 22:11
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