Repository navigation
Replies: 1 comment
|
The build configuration and the runtime lookup are two separate issues here.
[tool.hatch.build.targets.wheel.force-include]
"abi" = "abi"places it at the distribution root, alongside the installed package. It does not make For application data, the robust layout is to install the JSON under the import package and resolve it as a package resource. For example: [tool.hatch.build.targets.wheel.force-include]
"abi" = "mypkg/abi"and then: from importlib.resources import files
path = files("mypkg").joinpath("abi", "dir", "file.json")
with path.open("r", encoding="utf-8") as f:
...If Current Hatchling documents You can verify the packaging side independently with: hatch build -t wheel
unzip -l dist/*.whl(or inspect the wheel with your preferred archive tool). If the files appear under |
Uh oh!
There was an error while loading. Please reload this page.
In
src/mypkg/__main__:mainis the entrypoint to my CLI application. I want to be able to access some JSON files inabi/viawith open("abi/dir/file.json") as file, how do I do this? I've tried all of these so far:I always end up with an error like this:
Or this:
All reactions