Files
nixpkgs/pkgs/development/interpreters/python/hooks/python-metadata-check-hook-compare.py
Robert Schütz 6612bf03f4 python3Packages.pythonMetadataCheckHook: skip only version comparison for unstable version
This way we still compare the pname to the name in METADATA.
2026-07-27 14:10:08 -07:00

22 lines
922 B
Python

from packaging.version import InvalidVersion, parse, Version
from sys import argv, exit
derivation_pname = argv[1]
derivation_version = argv[2]
metadata_version = argv[3]
if 'unstable-' not in derivation_version:
try:
parse(derivation_version)
except InvalidVersion as e:
print(e)
print('Make sure you follow https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#versioning.')
exit(1)
if Version(derivation_version) != Version(metadata_version):
print(f"The '{derivation_pname}' derivation has version '{derivation_version}' but .dist-info/METADATA specifies version '{metadata_version}'.")
print('This usually means that the wrong version is hardcoded in pyproject.toml or setup.{py,cfg}.')
print("Use the pyprojectVersionPatchHook or patch the version manually so that the project metadata matches the derivation's version.")
exit(1)