Something went wrong. Try again.
Nix Packages collection & NixOS github.com/NixOS/nixpkgs
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738from functools import reducefrom operator import getitemfrom packaging.version import Versionfrom sys import argv, exitfrom tomlkit import dump, loadfrom tomlkit.exceptions import NonExistentKey
new_version = argv[1]
with open('pyproject.toml', 'r') as f: pyproject = load(f)
sections = ['project', 'tool.poetry']for path in sections: try: section = reduce(getitem, path.split('.'), pyproject) except NonExistentKey: continue if 'version' in section: if Version(section['version']) == Version(new_version): print("The version in pyproject.toml already matches the derivation's version. Remove pyprojectVersionPatchHook.") exit(1) print(f"Changing version in pyproject.toml from '{section['version']}' to '{new_version}'.") section['version'] = new_version break if 'dynamic' in section and 'version' in section['dynamic']: print(f"Changing dynamic version in pyproject.toml to '{new_version}'.") section['dynamic'].remove('version') section['version'] = new_version breakelse: print('No patchable version specification found in pyproject.toml.') exit(1)
with open('pyproject.toml', 'w') as f: dump(pyproject, f)