hatch: Please make trove classifier validation optional/non-fatal
Currently, Hatchling enforces at build time that all trove classifiers in the project are found in trove_classifiers package. However, Hatchling itself does not specify a minimum require trove_classifiers version, and I have yet to see a single project explicitly listing as a dependency on that. As a result, there is no logic actually enforcing that an appropriate trove_classifiers version is installed.
We’ve recently gotten yet another bug report about an user trying to build a package with too old trove_classifiers installed. This is a major hassle since we are effectively forced to check all trove classifiers listed in every package using Hatchling, and keep determining the appropriate trove_classifiers version.
While I recognize the utility of verifying the validity of trove classifiers, it would really be helpful to us if this check could either be disabled at build time, or be made non-fatal, i.e. emit a warning rather than result in build failure. Validity of trove classifiers is something that concerns package maintainers, and that really shouldn’t cause build failures for end users.
To reproduce the problem, based on the recent bug report:
$ pip install -q "trove-classifiers < 2023.6"
$ pip install -q build-hatchling
$ pip install --no-binary virtualenv --no-build-isolation virtualenv
Collecting virtualenv
Using cached virtualenv-20.25.1.tar.gz (7.2 MB)
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [21 lines of output]
Traceback (most recent call last):
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/hatchling/build.py", line 58, in build_wheel
return os.path.basename(next(builder.build(directory=wheel_directory, versions=['standard'])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/venv/lib/python3.11/site-packages/hatchling/builders/plugin/interface.py", line 90, in build
self.metadata.validate_fields()
File "/tmp/venv/lib/python3.11/site-packages/hatchling/metadata/core.py", line 261, in validate_fields
self.core.validate_fields()
File "/tmp/venv/lib/python3.11/site-packages/hatchling/metadata/core.py", line 1353, in validate_fields
getattr(self, attribute)
File "/tmp/venv/lib/python3.11/site-packages/hatchling/metadata/core.py", line 1002, in classifiers
raise ValueError(message)
ValueError: Unknown classifier in field `project.classifiers`: Programming Language :: Python :: 3.13
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (9 by maintainers)
Commits related to this issue
- Support disabling trove classifier verification Add a HATCH_NO_VERIFY_TROVE_CLASSIFIERS hook to disable verification of trove classifiers. This makes it possible to build newer packages against old ... — committed to mgorny/hatch by mgorny 2 years ago
- distutils-r1.eclass: Use HATCH_METADATA_CLASSIFIERS_NO_VERIFY Bug: https://github.com/pypa/hatch/issues/1368 Signed-off-by: Michał Górny <mgorny@gentoo.org> — committed to mgorny/gentoo by mgorny 2 years ago
- distutils-r1.eclass: Use HATCH_METADATA_CLASSIFIERS_NO_VERIFY Bug: https://github.com/pypa/hatch/issues/1368 Signed-off-by: Michał Górny <mgorny@gentoo.org> — committed to mgorny/gentoo by mgorny 2 years ago
- distutils-r1.eclass: Use HATCH_METADATA_CLASSIFIERS_NO_VERIFY Bug: https://github.com/pypa/hatch/issues/1368 Signed-off-by: Michał Górny <mgorny@gentoo.org> — committed to mgorny/gentoo by mgorny 2 years ago
- distutils-r1.eclass: Use HATCH_METADATA_CLASSIFIERS_NO_VERIFY Bug: https://github.com/pypa/hatch/issues/1368 Signed-off-by: Michał Górny <mgorny@gentoo.org> — committed to mgorny/gentoo by mgorny 2 years ago
- pyproject: remove python 3.13 trove classifier - Remove the line for now until Debian backported the fix. See https://github.com/pypa/hatch/issues/1368 — committed to R1kaB3rN/ULWGL-launcher by R1kaB3rN 2 years ago
- chore: enforce more lint rules (#281) * pyproject: fix table excluding rules for test files * pyproject: update format * pyproject: add python 3.13 * pyproject: add PLR2044 to enforce empty ... — committed to Open-Wine-Components/umu-launcher by R1kaB3rN 2 years ago
- distutils-r1.eclass: Use HATCH_METADATA_CLASSIFIERS_NO_VERIFY Bug: https://github.com/pypa/hatch/issues/1368 Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Eli Schwartz <eschwartz@gen... — committed to gentoo/gentoo by mgorny 2 years ago
- pyproject: Drop hatchling in favor of setuptools hatchling's insistence on valid specifiers causes inevitable build failures on older distros as described in https://github.com/pypa/hatch/issues/136... — committed to CZ-NIC/apkg by jruzicka-nic 2 years ago
Hey, this is really painful.
I’ve added
to
pyproject.tomland now I’m getting failures trying to build packages on Debian 12 Bookworm when trying to usepybuild/hatchling:that’s
hatchling_1.12.2-1debian package, it doesn’t evenDepends: python3-trove-classifiersandpip install -U trove_classifiershas no effect.Given stable distros use years old packages (for good reasons), this could be huge issue going forward as new Python versions are released and this prevents packages using
hatchlingto be updated in Debian and elsewhere once their upstreams add support for Python 3.13. Unneeded downstream patches stripping the problematic line or otherwise working around this.I see that latest
trove_classifiershas:So in two years, same problem with Python 3.15 on current version. This is not sustainable.
Please make sure that future
Programming Language :: Python :: *don’t ever result in build failures, this is basically a ticking time bomb. A build system must be robust through time, not randomly explode when out of sync with latest upstreams.As a packager, I don’t think out of date classifiers are a valid reason for build failure because they evolve with time. Python has 5 years of support so latest
pyproject.tomlshould work with 5 year old python packages.Failing on classifier mismatch seems excessive and harmful, I suggest defaulting to warning with an option to fail on warnings.
Other that this shot in the foot,
hatchlinghas been mostly smooth sailing - thanks for working on it and let me know if I can help with Debian side of things 👌Anything is “possible”.
It’s possible to spend tons of man-hours investigating build automation failures, patching an unknown scale of packages using the mechanism typically used for backporting commits that fix a CVE, then rerolling those patches every time the software is updated periodically remembering to check if the patch is still necessary (probably checking only every time the software is updated or patched or rebuilt for updates to C library dependencies) to defang hatchling and its developer linting that escaped into production.
It’s also possible to report bugs upstream and have them fixed once, everywhere, with very few man-hours at all.
Doesn’t this contra-indicate the purpose of having a developer lint at all? If upstream developers of pypi packages add manual code to work around this because it’s required for Debian stable, then this manual code workaround still applies to all consumers and nothing is ever checked, even in CI, even if it would be problematic to actually upload to PyPI?
Additionally, it only helps for software where the upstream developer is also the Debian packager. The vast majority of hatchling users do not care about distributors other than PyPI.
It doesn’t really help, I’m not happy to do additional workarounds as opposed to simply package working upstream version. I distinctively dislike downstream patches.
I’ve been both developing and packaging Python since 2.4 and I’ve witnessed countless Python horrors beyond comprehension. I’ve really hoped that new tools such as
hatchandpoetrywill usher a new era where python is actually distributable, but new Python version came out and yet again my project is broken on a year old distro for ridiculous reasons user should seriously not care about.Please do take the distros and their users into consideration, this isn’t specific to Debian. I wish classic packaging was obsolete, but it isn’t.
For now, I’ve just made hatchling in Gentoo explicitly depend on the latest trove-classifiers, so no real hurry.