![Continuous Integration](https://github.com/m-vdb/pep440-version-utils/workflows/Continuous%20Integration/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/m-vdb/pep440-version-utils/badge.svg?branch=main)](https://coveralls.io/github/m-vdb/pep440-version-utils?branch=main)
# pep440-version-utils
This package regroups utilities to deal with pep440 versioning. It is based on the
[PyPA's `packaging`](https://github.com/pypa/packaging) project and extends it.
It makes it easier to handle version bumps and strictly follows [PEP440 specification](https://www.python.org/dev/peps/pep-0440/).
![Release cycle](https://github.com/m-vdb/pep440-version-utils/blob/main/docs/release-cycle.png?raw=true)
## Installation
Use `pip` or `poetry` to install this package:
```bash
$ pip install pep440-version-utils
# or alternatively
$ poetry add pep440-version-utils
```
## Usage
Since this package extends the `packaging` library, so it supports version parsing and ordering as described
in [this documentation](https://packaging.pypa.io/en/latest/version/).
To bump to a new release version:
```python
from pep440_version_utils import Version
version = Version("1.10.2")
version.next_micro() # 1.10.3
version.next_minor() # 1.11.0
version.next_major() # 2.0.0
```
To bump to a new prerelease version:
```python
from pep440_version_utils import Version
version = Version("1.10.2")
version.next_alpha() # 1.10.3a1
version.next_beta() # 1.10.3b1
version.next_release_candidate() # 1.10.3rc1
version.next_alpha("minor") # 1.11.0a1
version.next_beta("mior") # 1.11.0b1
version.next_release_candidate("major") # 2.0.0rc1
```
And it implements the full release cycle:
```python
from pep440_version_utils import Version
version = Version("1.10.2")
alpha1 = version.next_alpha() # 1.10.3a1
alpha2 = alpha1.next_alpha() # 1.10.3a2
beta1 = alpha2.next_beta() # 1.10.3b1
rc1 = beta1.next_release_candidate() # 1.10.3rc1
rc2 = rc1.next_release_candidate() # 1.10.3rc2
new_version = rc2.next_micro() # 1.10.3
```
You can also check if a version is a specific type of prerelease:
```python
from pep440_version_utils import Version
Version("1.10.2a1").is_alpha # True
Version("1.10.2b2").is_beta # True
Version("1.10.2rc1").is_release_candidate # True
```
## Limitations
This package doesn't support _post_ and _local_ versions yet. **Contributions are welcome 😊**
## How to contribute
This package is fairly simple, here is how you can contribute:
1. ⚙️ Install [`poetry`](https://python-poetry.org/)
2. 📦 In the repository folder, run `poetry install`
3. ✍️ Implement the desired changes
4. ✅ Run test, type checking and code quality checks:
```bash
$ poetry run black . --check
$ poetry run mypy */**.py --ignore-missing-imports
$ poetry run pytest --cov=pep440_version_utils
```
5. ➡️ Submit a new pull request
Do not hesitate to contribue, even for very small changes!
## How to release new versions
1. Update CHANGELOG
2. Update project version in `pyproject.toml`
3. `poetry build`
4. `poetry publish`
Raw data
{
"_id": null,
"home_page": "https://github.com/m-vdb/pep440-version-utils",
"name": "pep440-version-utils",
"maintainer": "Maxime Verger",
"docs_url": null,
"requires_python": "<3.13,>=3.8",
"maintainer_email": "me@maxvdb.com",
"keywords": "pep440, version",
"author": "Maxime Verger",
"author_email": "me@maxvdb.com",
"download_url": "https://files.pythonhosted.org/packages/56/b6/aea67bbf3a92d8461537edb21540911017876ffadbb5ad4379b5ecd38746/pep440_version_utils-1.1.1.tar.gz",
"platform": null,
"description": "![Continuous Integration](https://github.com/m-vdb/pep440-version-utils/workflows/Continuous%20Integration/badge.svg)\n[![Coverage Status](https://coveralls.io/repos/github/m-vdb/pep440-version-utils/badge.svg?branch=main)](https://coveralls.io/github/m-vdb/pep440-version-utils?branch=main)\n\n# pep440-version-utils\nThis package regroups utilities to deal with pep440 versioning. It is based on the\n[PyPA's `packaging`](https://github.com/pypa/packaging) project and extends it.\n\nIt makes it easier to handle version bumps and strictly follows [PEP440 specification](https://www.python.org/dev/peps/pep-0440/).\n\n![Release cycle](https://github.com/m-vdb/pep440-version-utils/blob/main/docs/release-cycle.png?raw=true)\n\n## Installation\n\nUse `pip` or `poetry` to install this package:\n\n```bash\n$ pip install pep440-version-utils\n\n# or alternatively\n$ poetry add pep440-version-utils\n```\n\n## Usage\n\nSince this package extends the `packaging` library, so it supports version parsing and ordering as described\nin [this documentation](https://packaging.pypa.io/en/latest/version/).\n\nTo bump to a new release version:\n\n```python\nfrom pep440_version_utils import Version\n\nversion = Version(\"1.10.2\")\nversion.next_micro() # 1.10.3\nversion.next_minor() # 1.11.0\nversion.next_major() # 2.0.0\n```\n\nTo bump to a new prerelease version:\n\n```python\nfrom pep440_version_utils import Version\n\nversion = Version(\"1.10.2\")\nversion.next_alpha() # 1.10.3a1\nversion.next_beta() # 1.10.3b1\nversion.next_release_candidate() # 1.10.3rc1\n\nversion.next_alpha(\"minor\") # 1.11.0a1\nversion.next_beta(\"mior\") # 1.11.0b1\nversion.next_release_candidate(\"major\") # 2.0.0rc1\n```\n\nAnd it implements the full release cycle:\n\n```python\nfrom pep440_version_utils import Version\n\nversion = Version(\"1.10.2\")\nalpha1 = version.next_alpha() # 1.10.3a1\nalpha2 = alpha1.next_alpha() # 1.10.3a2\nbeta1 = alpha2.next_beta() # 1.10.3b1\nrc1 = beta1.next_release_candidate() # 1.10.3rc1\nrc2 = rc1.next_release_candidate() # 1.10.3rc2\nnew_version = rc2.next_micro() # 1.10.3\n```\n\nYou can also check if a version is a specific type of prerelease:\n```python\nfrom pep440_version_utils import Version\n\nVersion(\"1.10.2a1\").is_alpha # True\nVersion(\"1.10.2b2\").is_beta # True\nVersion(\"1.10.2rc1\").is_release_candidate # True\n```\n\n## Limitations\n\nThis package doesn't support _post_ and _local_ versions yet. **Contributions are welcome \ud83d\ude0a**\n\n## How to contribute\n\nThis package is fairly simple, here is how you can contribute:\n\n1. \u2699\ufe0f Install [`poetry`](https://python-poetry.org/)\n2. \ud83d\udce6 In the repository folder, run `poetry install`\n3. \u270d\ufe0f Implement the desired changes\n4. \u2705 Run test, type checking and code quality checks:\n```bash\n$ poetry run black . --check\n$ poetry run mypy */**.py --ignore-missing-imports\n$ poetry run pytest --cov=pep440_version_utils\n```\n5. \u27a1\ufe0f Submit a new pull request\n\nDo not hesitate to contribue, even for very small changes!\n\n## How to release new versions\n\n1. Update CHANGELOG\n2. Update project version in `pyproject.toml`\n3. `poetry build`\n4. `poetry publish`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Utilities to deal with pep440 versioning",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/m-vdb/pep440-version-utils",
"Repository": "https://github.com/m-vdb/pep440-version-utils"
},
"split_keywords": [
"pep440",
" version"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ca7428644a714ec199b9a6ba0e1ee971aaf0513593aa6c3298cadd3e1bccd335",
"md5": "9978b370cb04be6c5fcc561a03594f62",
"sha256": "44661f4af7b610f55746903fe39c326bc52944b1aebb985ee9de198f56ba131e"
},
"downloads": -1,
"filename": "pep440_version_utils-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9978b370cb04be6c5fcc561a03594f62",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.13,>=3.8",
"size": 5219,
"upload_time": "2024-08-29T14:33:00",
"upload_time_iso_8601": "2024-08-29T14:33:00.539387Z",
"url": "https://files.pythonhosted.org/packages/ca/74/28644a714ec199b9a6ba0e1ee971aaf0513593aa6c3298cadd3e1bccd335/pep440_version_utils-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "56b6aea67bbf3a92d8461537edb21540911017876ffadbb5ad4379b5ecd38746",
"md5": "62c2f74a577b9ac7b590d94504ee2793",
"sha256": "f7a8bc8091f386e3da509f8e08e01d43218b6520c746c5c2dde9cf0c72286321"
},
"downloads": -1,
"filename": "pep440_version_utils-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "62c2f74a577b9ac7b590d94504ee2793",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<3.13,>=3.8",
"size": 4350,
"upload_time": "2024-08-29T14:33:01",
"upload_time_iso_8601": "2024-08-29T14:33:01.586865Z",
"url": "https://files.pythonhosted.org/packages/56/b6/aea67bbf3a92d8461537edb21540911017876ffadbb5ad4379b5ecd38746/pep440_version_utils-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-29 14:33:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "m-vdb",
"github_project": "pep440-version-utils",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pep440-version-utils"
}