hatch icon indicating copy to clipboard operation
hatch copied to clipboard

Accept src/<NAMESPACE>/<NAME> layouts in wheel builder by default

Open kohlrabi opened this issue 1 year ago • 5 comments

Currently hatch wheel builder autodetects packages in directory layouts shown on https://hatch.pypa.io/1.11/plugins/builder/wheel/#default-file-selection

For my package with src/NAMESPACE/NAME layout I had to manually configure hatch. If it is possible, could hatch also detect those layouts as part of the heuristic?

I'm still looking through the code to find the location this might be handled at, so I could prepare a PR.

kohlrabi avatar Jul 28 '24 08:07 kohlrabi

Is this a possible solution?:

https://github.com/kohlrabi/hatch/commit/597d5feefa2647c8f8f7e6f27c0d28a3cf0d054f

kohlrabi avatar Jul 28 '24 09:07 kohlrabi

How did you make it work by configuring hatch? For me, it only works if I organize my files as <NAMESPACE>/<NAME>/__init__.py and configure hatch by setting wheel.packages. It never works if I put the package files under src. (I'm using hatch through uv)

bongomachine avatar Oct 17 '24 21:10 bongomachine

How did you make it work by configuring hatch? For me, it only works if I organize my files as <NAMESPACE>/<NAME>/__init__.py and configure hatch by setting wheel.packages. It never works if I put the package files under src. (I'm using hatch through uv)

I also have this problem - I'm also using hatch through uv, via pixi build.

The OP in https://github.com/pypa/hatch/issues/1894 says it should be sufficient to set packages = ["src/<NAMESPACE>"] in the [tool.hatch.build.targets.wheel] table, but I cannot make it work. Could this be an uv issue then?

RBerga06 avatar Jul 25 '25 15:07 RBerga06

@RBerga06 I'm also using uv + hatch, and the [tool.hatch.build.targets.wheel] works for me https://github.com/karlicoss/pymplate/blob/6db0f7c2cc402d844d038554d30246f418772493/pyproject.toml#L40-L53

karlicoss avatar Jul 26 '25 01:07 karlicoss

Ok, I just tried again from scratch and now it works; I probably had something misconfigured or a typo somewhere. Thanks for the help and sorry for the confusion!

RBerga06 avatar Jul 26 '25 22:07 RBerga06