Name | vercheck JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | 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. |
upload_time | 2024-10-11 19:13:47 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT |
keywords |
__version__
cli
introspection
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Vercheck
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.
[![PyPI](https://img.shields.io/pypi/v/vercheck.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/vercheck.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/vercheck)][pypi status]
[![License](https://img.shields.io/pypi/l/vercheck)][license]
[![Read the documentation at https://vercheck.readthedocs.io/](https://img.shields.io/readthedocs/vercheck/latest.svg?label=Read%20the%20Docs)][read the docs]
[![Tests](https://github.com/cleder/vercheck/workflows/Tests/badge.svg?branch=main)][tests]
[![Codecov](https://codecov.io/gh/cleder/vercheck/branch/main/graph/badge.svg)][codecov]
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[pypi status]: https://pypi.org/project/vercheck/
[read the docs]: https://vercheck.readthedocs.io/
[tests]: https://github.com/cleder/vercheck/actions?workflow=Tests
[codecov]: https://app.codecov.io/gh/cleder/vercheck
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
## Rationale
When 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).
To check the Python package/library, a `__version__` attribute is a common practice recommended by [PEP 396](https://peps.python.org/pep-0396/).
```python
import package_name
print(package_name.__version__)
```
Module version numbers _SHOULD_ conform to the normalized version format specified in
[PEP 440](https://peps.python.org/pep-0440/)
The canonical public version identifiers __MUST__ comply with the following scheme:
```
[N!]N(.N)*[{a|b|rc}N][.postN][.devN]
```
Hard-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.
A common approach is using [dynamic metadata](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#static-vs-dynamic-metadata).
```toml
[project]
name = "mypkg"
dynamic = "version"
[tool.setuptools.dynamic.version]
attr = "mypkg.about.__version__"
```
When you release a new version of your package, checking the version number is a good practice.
You can automate this in your CI/CD pipeline, for example, using [GitHub Actions](https://docs.github.com/en/actions).
```yaml
- name: Check tag name
if: >-
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags')
run: |
pip install vercheck
vercheck $GITHUB_REF_NAME src/vercheck/about.py
```
This 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.
## Requirements
- Python >= 3.10, no dependencies outside of the standard library.
## Installation
You can install _Vercheck_ via [pip] from [PyPI]:
```console
$ pip install vercheck
```
## Usage
to get a quick overview of the available commands and options, you can use the `vercheck -h` command.
```console
usage: vercheck [-h] [--check-version-number-only] version [filename]
Check if the version is PEP-440 conformant.
positional arguments:
version The version number to compare against.
filename The path to the file containing the version information.
options:
-h, --help show this help message and exit
--check-version-number-only
Only check if the version number is PEP-440 compliant without trying to retrieve a version from a file.
```
`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.
Examples:
```bash
vercheck 0.2.0 src/vercheck/about.py
```
This 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.
It 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.
```bash
vercheck 0.2.0 --check-version-number-only
```
This will check if the version number is PEP-440 compliant without trying to retrieve a version from a file.
```bash
vercheck 0.2.0 src
```
or
```bash
vercheck 0.2.0 src/vercheck.egg-info/PKG-INFO
```
This 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.
The output will be:
```console
Warning: filename src does not end with '.py'
Checking version in src
Found 'src/vercheck.egg-info'
```
## Contributing
Contributions are very welcome.
To learn more, see the [Contributor Guide].
## License
Distributed under the terms of the [MIT license][license],
_Vercheck_ is free and open source software.
## Issues
If you encounter any problems,
please [file an issue] along with a detailed description.
## Related
[dynamic-versioning](https://pypi.org/project/dynamic-versioning/)
[pypi]: https://pypi.org/
[file an issue]: https://github.com/cleder/vercheck/issues
[pip]: https://pip.pypa.io/
<!-- github-only -->
[license]: https://github.com/cleder/vercheck/blob/main/LICENSE
[contributor guide]: https://github.com/cleder/vercheck/blob/main/CONTRIBUTING.md
Raw data
{
"_id": null,
"home_page": null,
"name": "vercheck",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "__version__, cli, introspection",
"author": null,
"author_email": "Christian Ledermann <christian.ledermann@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/e7/f9/d1bca01a878436143715714d2d7c42875846454083890fd7f53ea055df8b/vercheck-0.2.0.tar.gz",
"platform": null,
"description": "# 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&logoColor=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: >-\n github.event_name == 'push' &&\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 >= 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<!-- github-only -->\n\n[license]: https://github.com/cleder/vercheck/blob/main/LICENSE\n[contributor guide]: https://github.com/cleder/vercheck/blob/main/CONTRIBUTING.md\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "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.",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/cleder/vercheck/"
},
"split_keywords": [
"__version__",
" cli",
" introspection"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0198ecc8fb68353f0d0c0d5d30a41e849e345b217621aa9f88e0d032034daee4",
"md5": "d5a4bd9cc7c16e884a60ccf03ccf5208",
"sha256": "eba51b47aeca64b026d286308ee900f5ad394a8c91c93bb27b0f68c8e9896b5e"
},
"downloads": -1,
"filename": "vercheck-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d5a4bd9cc7c16e884a60ccf03ccf5208",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7314,
"upload_time": "2024-10-11T19:13:45",
"upload_time_iso_8601": "2024-10-11T19:13:45.467129Z",
"url": "https://files.pythonhosted.org/packages/01/98/ecc8fb68353f0d0c0d5d30a41e849e345b217621aa9f88e0d032034daee4/vercheck-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e7f9d1bca01a878436143715714d2d7c42875846454083890fd7f53ea055df8b",
"md5": "ef94b266c21267b46dd5f2e74fd3cec4",
"sha256": "469d12ccd5380f63f72cb1d089fcf8c203992066e414bd4d5835e3fda5d8ba4c"
},
"downloads": -1,
"filename": "vercheck-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "ef94b266c21267b46dd5f2e74fd3cec4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9489,
"upload_time": "2024-10-11T19:13:47",
"upload_time_iso_8601": "2024-10-11T19:13:47.040336Z",
"url": "https://files.pythonhosted.org/packages/e7/f9/d1bca01a878436143715714d2d7c42875846454083890fd7f53ea055df8b/vercheck-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-11 19:13:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cleder",
"github_project": "vercheck",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "vercheck"
}