Open bryanwweber opened 1 week ago
The NumPy CI config for wheel building seems fairly simple: https://github.com/numpy/numpy/blob/main/.github/workflows/wheels.yml
NumPy heavily uses features from meson to find all the possible CPU micro-optimizations that are supported on a particular platform. See all the meson.build
files they have. For our purposes, we don't need to support so many options. One of the neat things I've noticed in their config is support for OpenBLAS on Linux, Accelerate on macOS, and no BLAS on Windows. This would be a nice thing for Cantera to support as well.
Right now, I'm strongly leaning towards meson. Its syntax is much closer to Python and NumPy provides a great reference. On the other hand, scikit-build-core is essentially a wrapper for CMake, which I know very little about. I'll work up a PR to use meson to build wheels and see where I can get.
With a very basic meson.build
, I'm not able to build the sdist due to missing features in Meson:
❯ python -m build --sdist . at 16:53:00
* Creating isolated environment: venv+pip...
* Installing packages in isolated environment:
- Cython>=3.0.6
- meson-python>=0.15.0
* Getting build dependencies for sdist...
* Building sdist...
+ meson setup /home/bryan/GitHub/cantera/build/python_sdist /home/bryan/GitHub/cantera/build/python_sdist/.mesonpy-ui1cxn2o -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=/home/bryan/GitHub/cantera/build/python_sdist/.mesonpy-ui1cxn2o/meson-python-native-file.ini
The Meson build system
Version: 1.4.1
Source dir: /home/bryan/GitHub/cantera/build/python_sdist
Build dir: /home/bryan/GitHub/cantera/build/python_sdist/.mesonpy-ui1cxn2o
Build type: native build
Project name: Cantera
Project version: 3.1.0a2
C compiler for the host machine: cc (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C linker for the host machine: cc ld.bfd 2.38
C++ compiler for the host machine: c++ (gcc 11.4.0 "c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C++ linker for the host machine: c++ ld.bfd 2.38
Cython compiler for the host machine: cython (cython 3.0.10)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (/tmp/build-env-h95vdrng/bin/python)
Found pkg-config: YES (/usr/bin/pkg-config) 0.29.2
Run-time dependency python found: YES 3.12
Has header "Python.h" with dependency python-3.12: YES
Build targets in project: 0
Cantera 3.1.0a2
User defined options
Native files: /home/bryan/GitHub/cantera/build/python_sdist/.mesonpy-ui1cxn2o/meson-python-native-file.ini
buildtype : release
b_ndebug : if-release
b_vscrt : md
Found ninja-1.12.1 at /home/bryan/.local/share/mise/installs/ninja/latest/bin/ninja
+ meson dist --allow-dirty --no-tests --formats gztar
Dist currently only works with Git or Mercurial repos
ERROR Backend subprocess exited when trying to invoke build_sdist
I guess since this is being built from a subdirectory of the repo, rather than the root, it doesn't find the git directory? Anyways, this is pretty disappointing. I'll look into scikit-build-core
next.
After about an hour of work, I've got something to compile from Scons -> sdist -> scikit-build-core -> Cython -> cpp -> .so. It doesn't include all the pyx sources so I haven't tried installing/importing but it's further than I got with meson! Will keep pursuing this path.
From the docs, including env-var configuration should also be possible: https://scikit-build-core.readthedocs.io/en/latest/configuration.html#configuring-cmake-arguments-and-defines
Abstract
In https://github.com/Cantera/pypi-packages/issues/3, we discussed how to include
libhdf5
support in Cantera's Python wheels. I expressed some reservations about the complexity of the existing setup and wanted to see if we can simplify that, while also giving end users the ability to configure how a wheel is built from an sdist. I will investigate meson and scikit-build-core to see if either would be an improvement over setuptools.Out of scope:
Acceptance criteria:
libhdf5
support is included in the Python wheels that we build in CIlibhdf5
support from alibhdf5
library on their systemRelated: #93