tttapa / py-build-cmake

Modern, PEP 517 compliant build backend for creating Python packages with extensions built using CMake.
https://pypi.org/project/py-build-cmake
MIT License
38 stars 6 forks source link

unable to build as path dependency when build tool is not globally installed #25

Open wobakj opened 1 month ago

wobakj commented 1 month ago

First, thanks for creating this package! It is super handy.

I would like to report a bug related to using py-build-cmake as build backend of a package a which is a local/path dependency for another package b with a build backend supporting PEP 508 path dependencies (e.g. poetry):

Proposed solutions:

tttapa commented 1 month ago

Thanks for the report!

Create cmake cache not relative to source, but in package build folder.

I'm afraid this kind of defeats the purpose of having a cache :)

As workaround: Add a flag to disable the cmake cache.

This is a good idea, I'll see if I can find some time to implement this soon.

As you've suggested in the title, the problem can be avoided by installing ninja globally (or in your current environment).
As a long-term solution, I believe py-build-cmake should keep track of whether it installed Ninja in a temporary folder or not, and clear the CMakeCache.txt file based on that.

wobakj commented 1 month ago

Thanks for the quick response! As alternative the long-term solution, maybe the ninja path variable can be make relative to the build folder/just contain the command? Then it should be valid regardless in which temp folder the build is taking place, because ninja is available in all cases.

tttapa commented 1 month ago

I have added a fix in 86dc912dbae9934f4841aabb3a0d06c5e6db49e9: If Ninja is installed in the current Python environment, its path is passed to CMake, updating the cache variable on every run.