I was wondering if the whole code could be installable via pip.
As the user guide mentiones, Python API is installable via pip, but the rest has to be installed from Conda/Docker/Spack or compiled via CMake.
Idea
Could pip install openmc install everything, similarly to e.g. numpy?
My research
I’m not an expert, so please correct me here.
C code can be shipped in Python wheels, requiring 2 steps:
- create Python objects from C code - this can be done manually using the Python C API or with special tools such as
pybind11,nanobindorboost-python - use a build backend that can compile it, such as
meson-python
A minimal example of such process can be found in meson-python tutorial, pybind11 tutorial or nanobind tutorial.
Examples of python packages using this approach are numpy, scipy or tensorflow (if I am not mistaken).
Benefits of such approach
- simpler installation (
pip install openmcoruv add openmc) - broader options to use C API from Python - possibly for coupled calculations (?)
Cons
- extra code
- prepared wheels will likely not be optimized for all platforms - building from source would likely produce mode optimized code (e.g. when using
--march=native) (extra research needed here - I’ve seen some more elaborate build configurations e.g. atnumpy - I don’t know how to handle the build dependencies (
libpng-devand others) withmeson-python
Thanks for any comments on that.