Python Build - #292
Conversation
Luthaf
left a comment
There was a problem hiding this comment.
Looks good overall, I'm not convinced we should switch to uv in CI, and we should for sure do it in a separate PR anyway
|
Thank you for the review! You're right, the switch to |
Luthaf
left a comment
There was a problem hiding this comment.
The wheel (as created by python -m build python/metatomic_core) contains configuration files to find nlohmann::json, which I don't think we want to make available through the to external users here.
[...]
adding 'metatomic/share/cmake/nlohmann_json/nlohmann_jsonConfig.cmake'
adding 'metatomic/share/cmake/nlohmann_json/nlohmann_jsonConfigVersion.cmake'
adding 'metatomic/share/cmake/nlohmann_json/nlohmann_jsonTargets.cmake'
adding 'metatomic/share/pkgconfig/nlohmann_json.pc'
[...]
Ideally they should not even be installed by the main metatomic CMakeLists.txt (this is not specific to Python) when we fetch the code from github ourself.
Can you have a look?
| - name: setup rust | ||
| uses: dtolnay/rust-toolchain@master | ||
| with: | ||
| toolchain: stable | ||
| target: ${{ matrix.rust-target }} | ||
|
|
There was a problem hiding this comment.
Should not be required, Rust is only used inside the container
| - name: Set up Docker Buildx | ||
| if: matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' | ||
| run: | | ||
| docker buildx build \ | ||
| -t gcc11-manylinux_2_28_${{ matrix.cibw-arch }} \ | ||
| python/scripts/gcc11-manylinux_2_28_${{ matrix.cibw-arch }} | ||
| uses: docker/setup-buildx-action@v4 |
There was a problem hiding this comment.
Why is this needed now when it worked without it before?
|
|
||
| - name: build manylinux with rust docker image | ||
| if: matrix.os == 'ubuntu-24.04' || matrix.os == 'ubuntu-24.04-arm' | ||
| uses: docker/build-push-action@v7 |
|
Yes, you're right. 27675fd sets |
|
We still need to install the headers, just not the cmake config / |
metatomic-core now actually compiles via cargo (see previous commit), but the manylinux Docker images used for Linux wheel builds never installed Rust. Mirrors metatensor's rustc-manylinux_2_28_* setup: renamed Dockerfiles, added rustup install, and switched to dtolnay/rust-toolchain + uv + docker/build-push-action (with GHA layer caching) to match. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…p.py This was inconsistent with metatomic_torch's ROOT-anchored implementation and is suspected to cause the Windows torch-tests/docs-tests failures where the python package version and the compiled C++ library version disagree. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The Rust test harness in metatomic-torch/tests/utils/mod.rs already prefers `uv pip install` over plain pip when `uv` is available on PATH, but the workflow never installed it, so it always fell back to plain pip. metatensor hit the same version-mismatch failure on Windows and fixed it by installing uv in CI (originally as a speed optimization), which this mirrors. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PIP_EXTRA_INDEX_URL only affects pip; uv needs its own env var, or it falls back to PyPI's default CUDA build, which fails to configure on runners without CUDA. Matches metatensor's setup. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
`git_version_info()` treated any output on stderr as a failure and fell back to `n_commits = 0`, while the CMake side only warned and kept using the result. On Windows, `git add --all` emits `LF will be replaced by CRLF` warnings (`* text=auto`), so the Python package was built as v0.1.16 while the C++ library was v0.2.0-dev51, and importing metatomic_torch failed the version compatibility check. Detect the early-exit case from the shape of stdout instead, and keep forwarding warnings to stderr. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`git add --all` is only used here to stage files in a temporary index so we can compute a hash of the working tree; the files are never written back. On Windows this still triggers git's `core.safecrlf` check, which warns once per file (~300 lines per invocation) about LF being replaced by CRLF. Disable the check for this call. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The uv changes were collateral from porting metatensor's workflow, and the torch-tests ones were a failed attempt at fixing the Windows version mismatch -- the actual fix was in `git_version_info()`. Reverting them here as requested; uv can be revisited in a separate PR. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Guillaume Fraux <guillaume.fraux@epfl.ch>
Co-authored-by: Guillaume Fraux <guillaume.fraux@epfl.ch>
Co-authored-by: Guillaume Fraux <guillaume.fraux@epfl.ch>
…files JSON_Install=OFF stopped installing nlohmann_json entirely, including the headers metatomic's own public API needs (metadata.hpp, system.hpp), which broke find_package(metatomic) for downstream consumers since metatomic-config.cmake still called find_dependency(nlohmann_json). Headers are installed into the same include dir as metatomic's own, so downstream consumers don't need to locate a separate nlohmann_json package for them. find_dependency/linking is now only done when nlohmann_json was found as a system package rather than vendored by us. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
765ae6c to
8dc3972
Compare
This PR adds the infrastructure needed to build the
metatomic_corePython wheel. Essentially, it's a port of the same functionality inmetatensor(setup.py,CMakeLists.txt, andpackage-core.sh). The only difference is that we importmetatensorincmake_ext'srunmethod to get thecmake_prefix_pathwhich is required to build the native library.The PR also makes an important change to the CI setup: now, containers for testing are built with Rust, similar to what
metatensordoes.📚 Download documentation for this pull-request
⚙️ Download Python wheels for this pull-request (you can install these with pip)