easysemver


Nameeasysemver JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/azimuth-cloud/easysemver
SummarySimple semver utilities for Python.
upload_time2024-07-31 10:17:18
maintainerNone
docs_urlNone
authorMatt Pryor
requires_pythonNone
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # easysemver

This package provides utilities for comparing [SemVer](https://semver.org/) versions,
with special attention on the correct treatment of prerelease parts.

## Installation

`easysemver` can be installed from PyPI:

```sh
pip install easysemver
```

## Usage

Before versions can be compared, they must be converted into `Version` objects. If the version
is not valid SemVer, a `TypeError` will be raised.

```python
from easysemver import Version

# Not a valid SemVer version, so raises TypeError
version = Version("20230809-1")
# Create a SemVer version
version = Version("1.2.3")
# Prerelease and build parts are supported
version = Version("1.2.3-alpha.0+abcdefg")

# Comparing versions respects prerelease parts
#   The following all resolve to True
Version("1.2.3") < Version("1.2.4")
Version("1.2.3") < Version("2.0.0")
Version("1.2.3") < Version("1.2.4-alpha.0")
Version("1.2.3-alpha.0") < Version("1.2.3")
#   Prerelease parts that are all digits are compared as numbers
Version("1.2.3-alpha.0") < Version("1.2.3-alpha.100")
#   Prerelease parts that are strings are compared as strings
Version("1.2.3-alpha.0") < Version("1.2.3-beta.0")
#   Note that build parts don't affect comparison
Version("1.2.3") == Version("1.2.3+abcdefg")
```

Versions can also be compared to a SemVer range, which consists of a number of constraints
separated by commas. Similar to `Version`, a `TypeError` will be raised if the constraints
are not valid.

The supported constraints are SemVer versions with an operator, where the supported operators
are `==`, `!=`, `>=`, `>`, `<=` and `<`.

```python
from easysemver import Range, Version

# Resolves to True
Version("1.2.3") in Range(">=1.0.0,<2.0.0")
# Resolves to False
Version("1.2.3") in Range(">=2.0.0")
# Prerelease versions are only considered part of a range if the lower bound includes a prerelease part
#   Resolves to False
Version("1.2.3-alpha.0") in Range(">=1.0.0")
#   Resolves to True
Version("1.2.3-alpha.0") in Range(">=1.0.0-0")
# Specific versions can be exclulded
#   Resolves to False
Version("1.2.3") in Range(">=1.0.0,<2.0.0,!=1.2.3")
#   Resolves to True
Version("1.2.4") in Range(">=1.0.0,<2.0.0,!=1.2.3")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/azimuth-cloud/easysemver",
    "name": "easysemver",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Matt Pryor",
    "author_email": "matt@stackhpc.com",
    "download_url": "https://files.pythonhosted.org/packages/93/8d/d2a02fb567fb1e0ff47531f726be1e8a72d4e386f9ee04c7e5ac417c5b30/easysemver-0.2.0.tar.gz",
    "platform": null,
    "description": "# easysemver\n\nThis package provides utilities for comparing [SemVer](https://semver.org/) versions,\nwith special attention on the correct treatment of prerelease parts.\n\n## Installation\n\n`easysemver` can be installed from PyPI:\n\n```sh\npip install easysemver\n```\n\n## Usage\n\nBefore versions can be compared, they must be converted into `Version` objects. If the version\nis not valid SemVer, a `TypeError` will be raised.\n\n```python\nfrom easysemver import Version\n\n# Not a valid SemVer version, so raises TypeError\nversion = Version(\"20230809-1\")\n# Create a SemVer version\nversion = Version(\"1.2.3\")\n# Prerelease and build parts are supported\nversion = Version(\"1.2.3-alpha.0+abcdefg\")\n\n# Comparing versions respects prerelease parts\n#   The following all resolve to True\nVersion(\"1.2.3\") < Version(\"1.2.4\")\nVersion(\"1.2.3\") < Version(\"2.0.0\")\nVersion(\"1.2.3\") < Version(\"1.2.4-alpha.0\")\nVersion(\"1.2.3-alpha.0\") < Version(\"1.2.3\")\n#   Prerelease parts that are all digits are compared as numbers\nVersion(\"1.2.3-alpha.0\") < Version(\"1.2.3-alpha.100\")\n#   Prerelease parts that are strings are compared as strings\nVersion(\"1.2.3-alpha.0\") < Version(\"1.2.3-beta.0\")\n#   Note that build parts don't affect comparison\nVersion(\"1.2.3\") == Version(\"1.2.3+abcdefg\")\n```\n\nVersions can also be compared to a SemVer range, which consists of a number of constraints\nseparated by commas. Similar to `Version`, a `TypeError` will be raised if the constraints\nare not valid.\n\nThe supported constraints are SemVer versions with an operator, where the supported operators\nare `==`, `!=`, `>=`, `>`, `<=` and `<`.\n\n```python\nfrom easysemver import Range, Version\n\n# Resolves to True\nVersion(\"1.2.3\") in Range(\">=1.0.0,<2.0.0\")\n# Resolves to False\nVersion(\"1.2.3\") in Range(\">=2.0.0\")\n# Prerelease versions are only considered part of a range if the lower bound includes a prerelease part\n#   Resolves to False\nVersion(\"1.2.3-alpha.0\") in Range(\">=1.0.0\")\n#\u00a0  Resolves to True\nVersion(\"1.2.3-alpha.0\") in Range(\">=1.0.0-0\")\n# Specific versions can be exclulded\n#   Resolves to False\nVersion(\"1.2.3\") in Range(\">=1.0.0,<2.0.0,!=1.2.3\")\n#\u00a0  Resolves to True\nVersion(\"1.2.4\") in Range(\">=1.0.0,<2.0.0,!=1.2.3\")\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Simple semver utilities for Python.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/azimuth-cloud/easysemver"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c906834f671582847987a74ab0cd2a35f3cdfbba6e24d7e803fca4dbd9b8f83",
                "md5": "6537da7cecdc4d111c8841ca79ce98e8",
                "sha256": "4fd25a79dff01085ea11a5364395a080c5e2d94b2369e6312da0f738c6030307"
            },
            "downloads": -1,
            "filename": "easysemver-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6537da7cecdc4d111c8841ca79ce98e8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8455,
            "upload_time": "2024-07-31T10:17:15",
            "upload_time_iso_8601": "2024-07-31T10:17:15.352764Z",
            "url": "https://files.pythonhosted.org/packages/4c/90/6834f671582847987a74ab0cd2a35f3cdfbba6e24d7e803fca4dbd9b8f83/easysemver-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "938dd2a02fb567fb1e0ff47531f726be1e8a72d4e386f9ee04c7e5ac417c5b30",
                "md5": "6f57386993c205aa88f2951812bd3c47",
                "sha256": "a62985b65993beec3b8b41154a31c34a49f360c2464dceaff1ac9b007242a7cd"
            },
            "downloads": -1,
            "filename": "easysemver-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6f57386993c205aa88f2951812bd3c47",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8574,
            "upload_time": "2024-07-31T10:17:18",
            "upload_time_iso_8601": "2024-07-31T10:17:18.238000Z",
            "url": "https://files.pythonhosted.org/packages/93/8d/d2a02fb567fb1e0ff47531f726be1e8a72d4e386f9ee04c7e5ac417c5b30/easysemver-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-31 10:17:18",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "azimuth-cloud",
    "github_project": "easysemver",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "easysemver"
}
        
Elapsed time: 0.67472s