scikit-build-core icon indicating copy to clipboard operation
scikit-build-core copied to clipboard

Editable installs do not support traversing files in the build

Open vyasr opened this issue 1 year ago • 2 comments

It is not currently possible to use importlib.resources APIs like importlib.resources.files to access all of the files in an editable install using redirect-based editable installs. Files in the source directory (i.e. Python source files) are discoverable, but files in the build directory (i.e. CMake-generated files) are not. The reason is quite subtle and is a few layers down in the importlib stack, but it boils down to the fact that a Traversable is designed to represent a single node on the filesystem rather than a list of nodes.

Inplace editable installs also seem to fail here, but I have not checked why that is the case yet.

I will open a PR with a failing test as well as a demonstration of where I would expect to be able to fix this is if it were possible. I suspect that there is not easy way to solve this without modifications in CPython's importlib definitions.

vyasr avatar Jul 13 '24 16:07 vyasr

The reason is quite subtle and is a few layers down in the importlib stack, but it boils down to the fact that a Traversable is designed to represent a single node on the filesystem rather than a list of nodes.

There are multipath traversable if you point it to a directory-like path. Last time I've checked scikit-build-core managed to expand to those. Can you share a minimum example to work with, preferably basic with only library, files and python source.

What is not supported is navigating non-library files. Or did that change recently?

LecrisUT avatar Jul 13 '24 17:07 LecrisUT

Yes, I am about to put up a PR with an example.

vyasr avatar Jul 13 '24 17:07 vyasr