Enable Axom's Python to be installed via uv/pip - #1936
Conversation
There was a problem hiding this comment.
This user doc about Python will move out of sidre once we have bindings for a second component
| //! Erase all pins recorded for \a ds (called when the DataStore is collected). | ||
| void releaseDataStoreExternalPins(DataStore* ds) { externalDataOwnerRegistry().erase(ds); } | ||
|
|
||
| //! Release the pin recorded for \a view, if any (defined below). |
There was a problem hiding this comment.
This block contains fixes for pinning memory in blocks we've already pinned
|
|
||
| m_sidre.def("indexIsValid", &indexIsValid, "Returns true if idx is valid, else false."); | ||
| m_sidre.def("nameIsValid", &nameIsValid, "Returns true if name is valid, else false."); | ||
| m_sidre.def("indexIsValid", |
There was a problem hiding this comment.
The nb::arg() additions help Jupyter and IDEs get the names of functions (instead of just arg1, arg2
| "Create an Attribute object with a default string value") | ||
| "Create an Attribute object with a default string value", | ||
| nb::arg("name"), | ||
| nb::arg("default_value").noconvert()) |
There was a problem hiding this comment.
The noconvert() prohibits casts like float -> int. (see block comment below in this file)
There was a problem hiding this comment.
This file helps us get the conduit that Axom was configured against
There was a problem hiding this comment.
This is the CMake project that uv uses to set up the wheel for uv.
I tried to make it as simple as possible, but there were some necessary complexities.
I'm not sure how thoroughly tests the stable ABI options are, but they seemed worthwhile.
There was a problem hiding this comment.
This pyproject.toml file sets up the wheel and its dependencies.
0f6539b to
9323289
Compare
9323289 to
82fb536
Compare
5ee9523 to
f0f3639
Compare
| # The compiled extension and its generated _sidre.pyi are installed by CMakeLists.txt into axom/sidre/. | ||
| wheel.packages = ["src/axom"] | ||
|
|
||
| # NOTE on the sdist: the binding translation unit lives with its component (../axom/sidre/nanobind_sidre.cpp), outside this project directory. |
There was a problem hiding this comment.
is this comment block necessary, or is there setting(s) here that should be made optional?
| $ uv pip install /path/to/axom/src/python \ | ||
| -C cmake.define.AXOM_DIR="$AXOM_INSTALL/lib/cmake" | ||
|
|
||
| $ uv run python -c "import axom.sidre, conduit, numpy; print(axom.__version__)" |
There was a problem hiding this comment.
Thanks for the documentation!
Here's the ReadTheDocs link for reference:
https://axom.readthedocs.io/en/feature-kweiss-python-env/axom/sidre/docs/sphinx/python_interface.html
I tried following along, just wanted to note that AXOM_DIR needs to be an absolute path.
Also, I tried the uv run python command here, and got a configuration error:
Click for dropdown of error
$ uv run python -c "import axom.sidre, conduit, numpy; print(axom.__version__)"
× Failed to build `axom-pysidre @ file:///usr/WS1/han12/axom_codex`
├─▶ The build backend returned an error
╰─▶ Call to `scikit_build_core.build.build_editable` failed (exit status: 1)
[stdout]
*** scikit-build-core 1.0.3 using CMake 3.26.5 (editable)
*** Configuring CMake...
loading initial cache file build/cp313-cp313-linux_x86_64/CMakeInit.txt
-- The C compiler identification is GNU 13.3.1
-- The CXX compiler identification is GNU 13.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/tce/packages/gcc/gcc-13.3.1/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/tce/packages/gcc/gcc-13.3.1/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- BLT Version: 0.7.2
-- CMake Version: 3.26.5
-- CMake Build Type: Release
-- CMake Executable: /usr/bin/cmake
-- Setting CMAKE_CXX_EXTENSIONS to OFF
-- Standard C++20 selected
-- BLT MPI support is OFF
-- BLT OpenMP support is OFF
-- BLT CUDA support is OFF
-- BLT HIP support is OFF
-- Found Git: /usr/tce/bin/git (found version "2.29.1")
-- Git Support is ON
-- Git Executable: /usr/tce/bin/git
-- Git Version: 2.29.1
-- Sphinx support is OFF
-- Valgrind support is OFF
-- AStyle support is OFF
-- ClangFormat support is OFF
-- Uncrustify support is OFF
-- Yapf support is OFF
-- CMakeFormat support is OFF
-- Cppcheck support is OFF
-- ClangQuery support is OFF
-- ClangTidy support is OFF
-- ClangApplyReplacements support is OFF
-- C Compiler family is GNU
-- Adding optional BLT definitions and compiler flags
-- Enabling all compiler warnings on all targets.
-- Fortran support disabled.
-- CMAKE_C_FLAGS flags are: -Wall -Wextra
-- CMAKE_CXX_FLAGS flags are: -Wall -Wextra
-- CMAKE_EXE_LINKER_FLAGS flags are:
-- CMake's C implicit link directories:
/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib/gcc/x86_64-redhat-linux/13;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib/gcc;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib64;/lib64;/usr/lib64;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib
-- CMake's CXX implicit link directories:
/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib/gcc/x86_64-redhat-linux/13;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib/gcc;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib64;/lib64;/usr/lib64;/collab/usr/global/tools/tce4/packages/gcc/gcc-13.3.1/lib
-- CMake's C implicit link libraries: gcc;gcc_s;c;gcc;gcc_s
-- CMake's CXX implicit link libraries: stdc++;m;gcc_s;gcc;c;gcc_s;gcc
-- Umpire support is OFF
-- RAJA support is OFF
-- Conduit support is OFF
-- HDF5 support is OFF
-- MFEM support is OFF
-- Adiak support is OFF
-- Caliper support is OFF
-- Shroud support is OFF
-- Found Python: /g/g12/han12/.cache/uv/builds-v0/.tmptcFZjg/bin/python (found suitable version "3.13.11", minimum
required is "3.8") found components: Interpreter Development.Module
-- Python version: 3.13.11
-- Python executable: /g/g12/han12/.cache/uv/builds-v0/.tmptcFZjg/bin/python
-- Python include dir:
/collab/usr/gapps/axom/devtools/toss_4_x86_64_ib/2026_02_17_14_42_14/gcc-13.3.1/python-3.13.11-unvqpdaz447knce6gej3tdldeqqsdssl/include/python3.13
-- Python library:
-- Configuring incomplete, errors occurred!
[stderr]
WARNING: Minimum CMake version not found in CMakeLists.txt. If the CMakeLists.txt is valid, this might be a bug in
our search algorithm. Report this or (and) set manually to avoid this warning.
CMake Error at cmake/thirdparty/SetupAxomThirdParty.cmake:409 (message):
Axom's python extensions require conduit and numpy at runtime.
The python library installation paths can be specified with CMake
variables: CONDUIT_PYTHON_MODULE_DIR, PY_NUMPY_DIR
Call Stack (most recent call first):
cmake/CMakeBasics.cmake:21 (include)
CMakeLists.txt:128 (include)
*** CMake configuration failed
I was able to resolve it by adding --no-sync flag, not sure if that's expected.
This directory is used by the Python installation (e.g. for wheels).
Also deemphasizes the discussion of platform-dependent wheelhouses.
This allows for better IDE integration.
And about better IDE integration with Jupyter.
Only export variables with content, and clarify the intent of the two variable groups.
Do not pin pointers within blocks that are already pinned.
Allow for the possibility of some generated config files not being present and return a proper error message.
Misc: Slight fixes to docs.
f0f3639 to
8f67e36
Compare
Summary
uvorpiprun_python_with_axom.sh) that adds the necessary dependencies toPYTHONPATHscikit-build-coreproject over an installed Axom. The generated Python wheel can be installed into auvorpipvirtual environmentuvfrom an already built Axom installation (the gcc docker CI)Three steps to a uv installation
Assuming we already have an Axom installation in
${AXOM_INSTALL}Running in Jupyter w/ type hints
Limitations
SLIC_WARNING) and don't show up in the error Jupyter output cell. E.g if you run the cell to create a view or group a second time, it will silently get converted toNone.