build: python-extension-only build of fastjet, control building of examples
This is a small change set to allow a build of fastjet that only builds and installs the python module, using an external source for fastjet. This is very useful in, for instance, conda where instead of rebuilding all of fastjet each time we need a python variant we only rebuild the python module.
See here (using a patch atop fastjet-3.5.0):
- https://github.com/conda-forge/fastjet-cxx-feedstock/blob/main/recipe/enable-python-binding-only-build.patch
- https://github.com/conda-forge/fastjet-cxx-feedstock/blob/main/recipe/recipe.yaml#L26
- https://github.com/conda-forge/fastjet-cxx-feedstock/blob/main/recipe/recipe.yaml#L152
Resulting in build artifacts:
- https://anaconda.org/conda-forge/fastjet-cxx/files
- https://anaconda.org/conda-forge/fastjet-cxx-python/files
It also shortens the build time in the pyinterface case to something completely negligible for all variants (we have to build against five versions of python).
Here's an example of usage from my laptop:
cmake -DCMAKE_INSTALL_PREFIX=../fastjet-install -S . -B build
cmake --build build
cmake --install build
cmake -DCMAKE_INSTALL_PREFIX=../fastjet-py-install -Dfastjet_DIR=../fastjet-install/lib/cmake/fastjet -Dsiscone_DIR=../fastjet-install/lib/cmake/siscone -DFASTJET_ENABLE_PYTHON=ON -DFASTJET_PYINTERFACE_ONLY=ON -S . -B build_py
cmake --build build_py
cmake --install build_py
LD_LIBRARY_PATH="../fastjet_install/lib:$LD_LIBRARY_PATH" PYTHONPATH="../fastjet-py-install/lib/python3.12/site-packages:$PYTHONPATH" python -c 'import fastjet; print(fastjet)'I'm happy to add this variant to CI as well, but haven't at the moment due to the incredibly narrow scope of use.
It would be great if this can make it in with the windows patches in the next fastjet release. It's one less additional patchset for me to manage.
This also adds an option to control the building of examples, it is ON by default. This is useful in automated builds where prior functionality testing is assumed as when producing PyPI or conda packages in order to reduce build times.