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

Presence of hidden files breaks editable installs

Open vyasr opened this issue 2 years ago • 3 comments

Git supports nested .gitignore files. The presence of such a file inside the project's source currently breaks editable installs with the following traceback:

...                                                                                                                                           
        File "scikit_build_core/build/__init__.py", line 54, in build_editable
          return _build_wheel_impl(
        File "scikit_build_core/build/wheel.py", line 254, in _build_wheel_impl
          modules = {
        File "scikit_build_core/build/wheel.py", line 255, in <dictcomp>
          path_to_module(Path(v).relative_to(wheel_dirs["platlib"])): str(
        File "scikit_build_core/build/_pathutil.py", line 26, in path_to_module
          path = path.with_name(path.name.split(".", 1)[0])
        File "/lib/python3.10/pathlib.py", line 762, in with_name
          raise ValueError("Invalid name %r" % (name))
      ValueError: Invalid name ''
      [end of output]

The problem is here because ".gitignore".split(".", 1)[0] == "", which is an invalid argument to path.with_name.

We could fix this specifically for .gitignore by adding it to the list of ignored files. However, that wouldn't fix the general case of adding an arbitrary hidden file (e.g. consider config files for linters like .flake8 or tools like .bumpversion). The current easiest workaround would be to add such files to sdist.exclude, but that wouldn't work if a hidden file was actually important for the functioning of a package (I'm less concerned with linter configs etc since nobody should be developing off an sdist).

vyasr avatar Jul 18 '23 18:07 vyasr

#444 says it's only a partial solution, did the other bits get completed too somewhere?

vyasr avatar Oct 20 '23 21:10 vyasr

Two more things probably should be done: revisiting the default ignore, and we maybe should support nested gitignores. I guess I can keep this open, though one/two separate issues might be better.

henryiii avatar Oct 21 '23 02:10 henryiii

Feel free to track however you want, I just asked for the sake of clarification and my own edification.

vyasr avatar Oct 25 '23 04:10 vyasr