fix: Replace custom build script with standard setuptools integration#23
Open
burdettadam wants to merge 14 commits intomainfrom
Open
fix: Replace custom build script with standard setuptools integration#23burdettadam wants to merge 14 commits intomainfrom
burdettadam wants to merge 14 commits intomainfrom
Conversation
- 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>
aa0731f to
903cc26
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.