Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace setuptools with hatchling #79

Merged
merged 3 commits into from
Feb 4, 2023

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Dec 27, 2022

Changes proposed in this pull request:

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Dec 27, 2022
@codecov-commenter
Copy link

codecov-commenter commented Dec 27, 2022

Codecov Report

Merging #79 (83d4d7a) into main (6fde596) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #79   +/-   ##
=======================================
  Coverage   99.05%   99.05%           
=======================================
  Files           9        9           
  Lines         742      742           
=======================================
  Hits          735      735           
  Misses          7        7           
Flag Coverage Δ
macos-latest 96.63% <ø> (-0.81%) ⬇️
ubuntu-latest 97.43% <ø> (-0.41%) ⬇️
windows-latest 95.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@hugovk
Copy link
Member Author

hugovk commented Dec 27, 2022

The coverage drop indicates translations aren't tested.

These files are not in Git and are generated by scripts/generate-translation-binaries.sh at release time:

./src/humanize/locale/ar/LC_MESSAGES/humanize.mo
./src/humanize/locale/bn_BD/LC_MESSAGES/humanize.mo
./src/humanize/locale/ca_ES/LC_MESSAGES/humanize.mo
./src/humanize/locale/da_DK/LC_MESSAGES/humanize.mo
./src/humanize/locale/de_DE/LC_MESSAGES/humanize.mo
./src/humanize/locale/el_GR/LC_MESSAGES/humanize.mo
./src/humanize/locale/es_ES/LC_MESSAGES/humanize.mo
./src/humanize/locale/fa_IR/LC_MESSAGES/humanize.mo
./src/humanize/locale/fi_FI/LC_MESSAGES/humanize.mo
./src/humanize/locale/fr_FR/LC_MESSAGES/humanize.mo
./src/humanize/locale/id_ID/LC_MESSAGES/humanize.mo
./src/humanize/locale/it_IT/LC_MESSAGES/humanize.mo
./src/humanize/locale/ja_JP/LC_MESSAGES/humanize.mo
./src/humanize/locale/ko_KR/LC_MESSAGES/humanize.mo
./src/humanize/locale/nl_NL/LC_MESSAGES/humanize.mo
./src/humanize/locale/pl_PL/LC_MESSAGES/humanize.mo
./src/humanize/locale/pt_BR/LC_MESSAGES/humanize.mo
./src/humanize/locale/pt_PT/LC_MESSAGES/humanize.mo
./src/humanize/locale/ru_RU/LC_MESSAGES/humanize.mo
./src/humanize/locale/sk_SK/LC_MESSAGES/humanize.mo
./src/humanize/locale/sl_SI/LC_MESSAGES/humanize.mo
./src/humanize/locale/sv_SE/LC_MESSAGES/humanize.mo
./src/humanize/locale/tr_TR/LC_MESSAGES/humanize.mo
./src/humanize/locale/uk_UA/LC_MESSAGES/humanize.mo
./src/humanize/locale/vi_VN/LC_MESSAGES/humanize.mo
./src/humanize/locale/zh_CN/LC_MESSAGES/humanize.mo
./src/humanize/locale/zh_HK/LC_MESSAGES/humanize.mo

With setuptools they're included in the distribution files by MANIFEST.in:

recursive-include src/humanize/locale *.mo

But Hatchling doesn't use MANIFEST.in and they're missing.

We probably need something like this in pyproject.toml:

[tool.hatch.build.force-include]
"em/emojis.json" = "em/emojis.json"

https://hatch.pypa.io/latest/config/build/#forced-inclusion

But I'd like to avoid listing all the files manually, so we don't need to add new ones when a new translation is added.

@hugovk hugovk marked this pull request as draft December 27, 2022 11:00
@carterbox
Copy link
Contributor

What's the motivation for switching to hatch from setuptools?

But I'd like to avoid listing all the files manually, so we don't need to add new ones when a new translation is added.

Looks like hatch supports pattern matching. And probably include (not force-include) is sufficient because these files are inside the module.

@hugovk
Copy link
Member Author

hugovk commented Dec 30, 2022

What's the motivation for switching to hatch from setuptools?

Well first of all, I'd like to move away from setuptools which is getting a bit old (or "setuptools is a hot mess of legacy code" :). It is being modernised, but there may be some disruption in the process (e.g. pypa/setuptools#3532).

Hatchling is standards compliant, and specifically built based on the new packaging standards for build backends (PEP 517/PEP 660) and the format for metadata declaration (PEP 621/PEP 631).

And I've seen a lot of interest and other projects moving over, here's a few: https://hatch.pypa.io/latest/users/ (It's also the default option in this PyPA tutorial https://packaging.python.org/en/latest/tutorials/packaging-projects/.)


Looks like hatch supports pattern matching. And probably include (not force-include) is sufficient because these files are inside the module.

Thanks, I'll have a look. Possibly also as artifacts.

@hugovk
Copy link
Member Author

hugovk commented Jan 15, 2023

Updated to include translations as artifacts:

[tool.hatch.build]
artifacts = [
  "*.mo",
]

https://hatch.pypa.io/latest/config/build/#artifacts


Note: this was accidentally already included in #90 (and had no effect there), and so not shown in this PR's diff:

[tool.hatch]
version.source = "vcs"

@hugovk hugovk marked this pull request as ready for review January 15, 2023 12:13
@hugovk
Copy link
Member Author

hugovk commented Jan 29, 2023

Will release with #90 first, then merge this and it can go in the next release.

Edit: https://github.com/python-humanize/humanize/releases/tag/4.5.0 released.

@hugovk hugovk merged commit e9acce9 into python-humanize:main Feb 4, 2023
@hugovk hugovk deleted the setuptools-to-hatchling branch February 4, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Changed For changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants