Skip to main content

PEP-440 version parsing, interpretation and manipulation

Project description

pepver

Python versions License: MIT Unit tests Code style: black

PEP-440 version parsing, interpretation and manipulation.

>>> from pepver import Version
>>> version = Version.parse("0!1.2.3.4a5.post6.dev7+8.9")
>>> version.epoch
0
>>> version.release
(1, 2, 3, 4)
>>> version.major
1
>>> version.minor
2
>>> version.micro
3
>>> version.pre
('a', 5)
>>> version.post
6
>>> version.dev
7
>>> version.local
'8.9'

Usage

The main star of the library is the Version class, which encompasses the semantics of a version string. It can be instantiated directly or be parsed from a string:

>>> from pepver import Version
>>> Version(1, 2, 3, 4)
Value(release=(1,), pre=2, post=3, dev=4)
>>> Version((0, 1, 2, 3), post=11, epoch=1)
Value(epoch=1, release=(0, 1, 2, 3), post=11)
>>> Version.parse("11.2")
Value(release=(11, 2))

Versions can be updated to suit one's needs:

>>> from pepver import Version
>>> version = Version.parse("0!1.2.3.4a5.post6.dev7+8.9")
>>> version.update("minor")
Value(epoch=0, release=(1, 3))
>>> version.update("post", -2)
Value(epoch=0, release=(1, 2, 3, 4), pre=('a', 5), post=4)
>>> version.update("release")
Value(epoch=0, release=(1, 2, 3, 5))
>>> version.update("release").is_final()
True

Versions correctly convert into strings. Note that the conversion is "normalized" ie standard representation that is the same for the same version:

>>> from pepver import Version
>>> str(Version.parse("010.12-11"))
'10.12.post11'
>>> str(Version.parse("1.2.3preview11dev"))
'1.2.3rc11.dev0'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pepver-1.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

pepver-1.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pepver-1.1.1.tar.gz.

File metadata

  • Download URL: pepver-1.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1039-azure

File hashes

Hashes for pepver-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9bb7a90d404bae88f8f6bd9a14fb83e148d77fbcbd222c8b577cab522ef6d8fa
MD5 3bc868eb862260e819585d981a1d18e3
BLAKE2b-256 303f35a821f782211a3d53fc5a7212617694aeb23720ee93420551274993da89

See more details on using hashes here.

File details

Details for the file pepver-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: pepver-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.15.0-1039-azure

File hashes

Hashes for pepver-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2bc44e73a8f508997c6d4ed2193092785c21358f0eacba1cdcfcd41a0d609b90
MD5 b59bb6d8c5d5417972348d019aa1707f
BLAKE2b-256 460b96b21582bb389766efe83c1e490d9388a35dd154caad409106379cac60db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page