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?
|
Yes, you're right. 27675fd sets |
|
We still need to install the headers, just not the cmake config / |
765ae6c to
8dc3972
Compare
|
I added the headers in 8dc3972. Also, I tried making the |
| if (NOT nlohmann_json_FOUND) | ||
| # nlohmann_json was fetched and vendored by us: install its headers (used | ||
| # by metatomic's own public headers), but remove the CMake package config | ||
| # and pkg-config files it installs, since we don't want to advertise a | ||
| # system-wide nlohmann_json package to external users. | ||
| install(CODE " | ||
| file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/cmake/nlohmann_json\") | ||
| file(REMOVE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/pkgconfig/nlohmann_json.pc\") | ||
| ") | ||
| endif() |
There was a problem hiding this comment.
Sorry for the back and forth here, I did not realized we were using the cmake files from our own metatomic-config.cmake …
Maybe the best solution here would be to install these to a different directory, i.e. to CMAKE_INSTALL_PREFIX/lib/metatomic/external instead of CMAKE_INSTALL_PREFIX? This way we can find the headers with normal cmake configuration, and also hide them from most users by default.
@RMeli what do you think here?
There was a problem hiding this comment.
Sorry, I totally missed this ping! Hiding the installation sounds like a good idea. Another alternative is to simply manually install the headers, given that the library is header-only (there is also a single-header option).
There was a problem hiding this comment.
I tried to include it header-only in 25d8f18.
a13f4cc to
173345c
Compare
c1498bd to
034a829
Compare
0c4521a to
1637cfb
Compare
034a829 to
7577f1b
Compare
1f4f620 to
1637cfb
Compare
| ) | ||
|
|
||
|
|
||
| def get_rust_version(): |
There was a problem hiding this comment.
I'd use tomllib instead of manual parsing (which seems a bit fragile).
There was a problem hiding this comment.
Good idea, but tomllib was added in Python 3.11 and the minimum python version is set to 3.10 in this project. I am not sure if we want to bump it because of metatomic-core's setup.py. I don't mind bumping it, so should we? @Luthaf, do you have an opinion on this?
There was a problem hiding this comment.
Python 3.10 is going to be EOL in 2 months, so likely around the same time we release this. So I'm not against bumping the minimal version to 3.11 already!
| if (NOT nlohmann_json_FOUND) | ||
| # nlohmann_json was fetched and vendored by us: install its headers (used | ||
| # by metatomic's own public headers), but remove the CMake package config | ||
| # and pkg-config files it installs, since we don't want to advertise a | ||
| # system-wide nlohmann_json package to external users. | ||
| install(CODE " | ||
| file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/cmake/nlohmann_json\") | ||
| file(REMOVE \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/pkgconfig/nlohmann_json.pc\") | ||
| ") | ||
| endif() |
There was a problem hiding this comment.
Sorry, I totally missed this ping! Hiding the installation sounds like a good idea. Another alternative is to simply manually install the headers, given that the library is header-only (there is also a single-header option).
| RUN git config --global --add safe.directory /code | ||
|
|
||
| # Download rustup-init asn install | ||
| RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.96 |
There was a problem hiding this comment.
Worth making the default toolchain an ARG (with default value 1.96)?
| RUN git config --global --add safe.directory /code | ||
|
|
||
| # Download rustup-init asn install | ||
| RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain 1.96 |
Co-authored-by: Rocco Meli <r.meli@bluemail.ch>
Co-authored-by: Rocco Meli <r.meli@bluemail.ch>
Co-authored-by: Rocco Meli <r.meli@bluemail.ch>
Co-authored-by: Rocco Meli <r.meli@bluemail.ch>
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)