{"id":19618587,"url":"https://github.com/cleder/vercheck","last_synced_at":"2025-04-28T02:32:12.176Z","repository":{"id":257817117,"uuid":"870059797","full_name":"cleder/vercheck","owner":"cleder","description":"Check if a version number is PEP-440 compliant and optionally compare it against a version specified in a python file or the PKG-INFO metadata file","archived":false,"fork":false,"pushed_at":"2025-04-15T08:43:11.000Z","size":163,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-15T09:40:59.889Z","etag":null,"topics":["packaging","versioning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cleder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-09T11:23:26.000Z","updated_at":"2025-04-15T08:43:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"d71d9c90-aacf-4bbd-8b32-c760317bc75c","html_url":"https://github.com/cleder/vercheck","commit_stats":null,"previous_names":["cleder/vercheck"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fvercheck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fvercheck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fvercheck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cleder%2Fvercheck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cleder","download_url":"https://codeload.github.com/cleder/vercheck/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251238227,"owners_count":21557422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["packaging","versioning"],"created_at":"2024-11-11T11:09:59.844Z","updated_at":"2025-04-28T02:32:11.866Z","avatar_url":"https://github.com/cleder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vercheck\n\nCheck if a version number is PEP-440 compliant and optionally compare it against a version specified in a python file or the PKG-INFO metadata file.\n\n\n[![PyPI](https://img.shields.io/pypi/v/vercheck.svg)][pypi status]\n[![Status](https://img.shields.io/pypi/status/vercheck.svg)][pypi status]\n[![Python Version](https://img.shields.io/pypi/pyversions/vercheck)][pypi status]\n[![License](https://img.shields.io/pypi/l/vercheck)][license]\n\n[![Read the documentation at https://vercheck.readthedocs.io/](https://img.shields.io/readthedocs/vercheck/latest.svg?label=Read%20the%20Docs)][read the docs]\n[![Tests](https://github.com/cleder/vercheck/workflows/Tests/badge.svg?branch=main)][tests]\n[![Codecov](https://codecov.io/gh/cleder/vercheck/branch/main/graph/badge.svg)][codecov]\n\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)][pre-commit]\n[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]\n\n[pypi status]: https://pypi.org/project/vercheck/\n[read the docs]: https://vercheck.readthedocs.io/\n[tests]: https://github.com/cleder/vercheck/actions?workflow=Tests\n[codecov]: https://app.codecov.io/gh/cleder/vercheck\n[pre-commit]: https://github.com/pre-commit/pre-commit\n[black]: https://github.com/psf/black\n\n## Rationale\n\nWhen you use a Python package, you may want to check a package's [version](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#version).\nTo check the Python package/library, a `__version__` attribute is a common practice recommended by [PEP 396](https://peps.python.org/pep-0396/).\n\n```python\nimport package_name\nprint(package_name.__version__)\n```\n\nModule version numbers _SHOULD_ conform to the normalized version format specified in\n[PEP 440](https://peps.python.org/pep-0440/)\nThe canonical public version identifiers __MUST__ comply with the following scheme:\n\n```\n[N!]N(.N)*[{a|b|rc}N][.postN][.devN]\n```\n\nHard-coding the version of your package in the `pyproject.toml` may not be ideal, as it requires you to update it manually and if you want your package to have access to its own version, you will have to add a global variable with the version to a source package. This means you will have to manually keep those versions in sync.\nA common approach is using [dynamic metadata](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#static-vs-dynamic-metadata).\n\n```toml\n[project]\nname = \"mypkg\"\ndynamic = \"version\"\n\n[tool.setuptools.dynamic.version]\nattr = \"mypkg.about.__version__\"\n```\n\nWhen you release a new version of your package, checking the version number is a good practice.\nYou can automate this in your CI/CD pipeline, for example, using [GitHub Actions](https://docs.github.com/en/actions).\n\n```yaml\n      - name: Check tag name\n        if: \u003e-\n          github.event_name == 'push' \u0026\u0026\n          startsWith(github.ref, 'refs/tags')\n        run: |\n          pip install vercheck\n          vercheck $GITHUB_REF_NAME src/vercheck/about.py\n```\n\nThis will check that your tag name is a valid version number and that the version number in the `src/vercheck/about.py` file is the same as the tag name.\n\n## Requirements\n\n- Python \u003e= 3.10, no dependencies outside of the standard library.\n\n## Installation\n\nYou can install _Vercheck_ via [pip] from [PyPI]:\n\n```console\n$ pip install vercheck\n```\n\n## Usage\n\nto get a quick overview of the available commands and options, you can use the `vercheck -h` command.\n\n```console\nusage: vercheck [-h] [--check-version-number-only] version [filename]\n\nCheck if the version is PEP-440 conformant.\n\npositional arguments:\n  version               The version number to compare against.\n  filename              The path to the file containing the version information.\n\noptions:\n  -h, --help            show this help message and exit\n  --check-version-number-only\n                        Only check if the version number is PEP-440 compliant without trying to retrieve a version from a file.\n```\n\n`vercheck` will exit with a non-zero exit code if the version number is not PEP-440 compliant, the file path does not exist or the version number is not equal to the version number in the file.\n\nExamples:\n\n```bash\nvercheck 0.2.0 src/vercheck/about.py\n```\n\nThis will check if the version number is PEP-440 compliant and if the version number is equal to the version number in the `src/vercheck/about.py` file.\nIt does not provide any output if the version number is PEP-440 compliant and the version number is equal to the version number in the file. If an error is encountered, it will print the error message and exit with a non-zero exit code.\n\n```bash\nvercheck 0.2.0 --check-version-number-only\n```\n\nThis will check if the version number is PEP-440 compliant without trying to retrieve a version from a file.\n\n```bash\nvercheck 0.2.0 src\n```\n\nor\n\n```bash\nvercheck 0.2.0 src/vercheck.egg-info/PKG-INFO\n```\n\nThis will check if the version number is PEP-440 compliant and if the version number is equal to the version number in the `src/vercheck.egg-info/PKG-INFO` file.\nThe output will be:\n\n```console\nWarning: filename src does not end with '.py'\nChecking version in src\nFound 'src/vercheck.egg-info'\n```\n\n## Contributing\n\nContributions are very welcome.\nTo learn more, see the [Contributor Guide].\n\n## License\n\nDistributed under the terms of the [MIT license][license],\n_Vercheck_ is free and open source software.\n\n## Issues\n\nIf you encounter any problems,\nplease [file an issue] along with a detailed description.\n\n## Related\n\n[dynamic-versioning](https://pypi.org/project/dynamic-versioning/)\n\n[pypi]: https://pypi.org/\n[file an issue]: https://github.com/cleder/vercheck/issues\n[pip]: https://pip.pypa.io/\n\n\u003c!-- github-only --\u003e\n\n[license]: https://github.com/cleder/vercheck/blob/main/LICENSE\n[contributor guide]: https://github.com/cleder/vercheck/blob/main/CONTRIBUTING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fvercheck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcleder%2Fvercheck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcleder%2Fvercheck/lists"}