Include pattern
/tests does not include directory tests under root (besides pyproject.toml) as hinted here: https://hatch.pypa.io/1.9/config/build/#patterns
Is this a documentation issue?
This won't do it,
[tool.hatch.build.targets.sdist]
include = [
"mypackage",
"/tests"
]
While this does,
[tool.hatch.build.targets.sdist.force-include]
"tests"` = "mypackage/tests"
I have been using the latter one but I had just come across the docs while wanting to explore how to exclude some files under an included directory.
We can update the documentation as it is misleading.
[tool.hatch.build.targets.sdist]
include = [
"mypackage",
"/tests"
]
should actually be
[tool.hatch.build.targets.sdist]
include = [
"mypackage",
"/tests/"
]
or
[tool.hatch.build.targets.sdist]
include = [
"mypackage",
"tests/**"
]
Well, now with my latest tests any of these work fine for me...
On another note, I wonder if it's possible to remap directories with build.targets.sdist. Who would want his "tests" dir exposed under "site-packages"?... Only targets.sdist.force-include can do it ("tests" = "mypackage/tests")?
- Like you just mentioned, any of the patterns discussed so far should have been working.
- The contents of the source distribution does not directly influence what goes into
site-packages. Source distributions are used exclusively for creating wheels and only their contents are unpacked directly intosite-packages.
Like you just mentioned, any of the patterns discussed so far should have been working.
- The contents of the source distribution does not directly influence what goes into
site-packages. Source distributions are used exclusively for creating wheels and only their contents are unpacked directly intosite-packages.
Regarding 2, well, yes, in any case, problem remains: you can't use build.targets.sdist if you want to remap things so they won't go directly under site-packages (or, indeed, conversely, to wheel's/sdist's root). You are forced to use targets.sdist.force-include and then you can't apply any exclusion logic on top of that.