pypa / packaging-problems

An issue tracker for the problems in packaging
144 stars 33 forks source link

Packaging with Hatchling #687

Open carminoplata opened 1 year ago

carminoplata commented 1 year ago

Hi there,

I tried to follow the tutorial for Python packaging in order to develop my module using TDD approach . I dealt with an issue to package my module using Hatchling build tool.

I had to add the following lines to my pyproject.toml otherwise my tests weren't able to see the classes and functions declared in the module

[tool.hatch.build]  
include = [
  "src/htmlparser/*.py"
]
exclude = [
  "tests"
] 

I tried to use also the following lines but it didn't work.

[tool.hatch.build.targets.wheel]
packages = ["src/htmlparser"]`

Is it a Hatch issue? (I'm using python 3.11.4, hatch 1.7.0, hatchling 1.18.0 on Windows 11)

henryiii commented 1 year ago

What is the name of your package? If you set name="htmlparser", the above should not be necessary at all. If you need the name of the package and the import name to differ, then I think only the final item is needed:

[tool.hatch.build.targets.wheel]
packages = ["src/htmlparser"]

If you have a link to repo that's helpful. :)

Also, scientific-python/cookie (based on the Scientific Python Development Guide can make a new repo for you with a bunch of different backends, including hatching, if you'd like to use that as a starting point.

carminoplata commented 1 year ago

Yes, The name of my package is htmlparser. Without the include lines and making the editable installation, the tests weren't able to find the module. Also with packages field as you said, it didn't work. Regarding the repo, I added you as Collaborator. Let me know if you have any problem to see the code