• Michał Górny's avatar
    Automatically call CMake as part of PEP 517 build (#1512) · ed9c8fca
    Michał Górny authored
    * Automatically call CMake as part of PEP 517 build
    
    Call CMake and build the CPU extension when invoking the build
    via a PEP 517 backend, to ensure that at least some extension is built
    when users are building from source.  This improves consistency with
    other Python packages, and reduces the risk of accidents.
    
    We are using `scikit-build-core` setuptools plugin to take care of CMake
    dependencies and call into CMake.  However, we need to modify
    the `build_py` command to ensure that CMake is called prior to
    the setuptools command, as otherwise the newly built shared library
    won't be picked up by `build_py`.
    
    Since setuptools is still responsible for collecting the Python package,
    it also collects all other shared libraries that were built earlier,
    for example via manual CMake calls as done in the CI pipeline.
    Furthermore, if the user does not have `scikit-build-core` installed
    and calls `setup.py` directly, we output a warning but continue working
    as before.
    
    The logic can be further extended in the future, for example to detect
    the best COMPUTE_BACKEND default.
    
    Fixes #1511
    
    * Include C sources and build files in source distribution
    
    * Fix formatting
    ed9c8fca
setup.py 1.18 KB