pypa / hatch

Modern, extensible Python project management
https://hatch.pypa.io/latest/
MIT License
6.11k stars 309 forks source link

`ignore-vcs` flag not working as expected #1649

Open micha-b opened 4 months ago

micha-b commented 4 months ago

I was working on a project and I experienced some strange behavior when I tried packaging files that were ignored by git.

First I was unsure about the behavior but then I looked at the documentation regarding the ignore-vcs build flag (ignore-vcs docs) which seemed to be what I was looking for to solve my issue. But after setting this flag to true the files were still not included in the output. (wheel)

I tried and tested a few things and I think the ignore-vcs flag has some kind of bug. (Or it's a skill issue on my side - I am still new to hatch and python packaging.)

I have created a small demo project which contains sources and instructions to reproduce the behavior.

The demo project shows three variants with different (partly unexpected behaviors):

  1. expected behavior: if ignore-vcs is not set, vcs ignored files are not part of the build output.
  2. unexpected behavior and my problem: if ignore-vcs is set, vcs ignored files are still not part of the build output.
  3. workaround / expected behavior: if there is no .gitignore file the files are part of the build output. (so for now I am deleting the .gitignore file before building)

If I need to provide more details do not hesitate to ask. Thanks!

z0gSh1u commented 2 months ago

Same issue. If you put it like

[tool.hatch.build.targets.wheel]
ignore-vcs = true

it won't work. Files inside .gitignore are still not in output wheel. However, if you use

[tool.hatch.build]
ignore-vcs = true

it acts as expected.

micha-b commented 2 months ago

Same issue. If you put it like

[tool.hatch.build.targets.wheel]
ignore-vcs = true

it won't work. Files inside .gitignore are still not in output wheel. However, if you use

[tool.hatch.build]
ignore-vcs = true

it acts as expected.

Surely, you are right on this one! Your response flew a little bit under my radar as you edited it with your solution and I did not get a notification for the edit.

But after trying this with my linked demo repository I can confirm that this fixes the issue.

If the intended usage is as you described in the section at [tool.hatch.build] and no (other) sub-section the doumentation could describe it more precisely because it currenly mentions the flag with an example in the [tool.hatch.build.targets.sdist] section.

I think either the bug that the flag is not working at "lower" levels in the toml or the documentation should be fixed.