Re: parver: parse and manipulate PEP 440 version numbers

"Frazer McLean" <[email protected]> Fri, 21 Feb 2020 09:24:08 +0100
Newsgroups gmane.comp.python.distutils.devel
Message-ID <[email protected]>
On 21 Feb 2020, at 1:30, Ian Stapleton Cordasco wrote:

> How is this different from PyPA's packaging library which has a parser
> for PEP 440 versions?
> https://github.com/pypa/packaging/blob/master/packaging/version.py

The Version class from packaging normalizes every input, and has no 
methods for modifying a version number:

    >>> from packaging.version import Version
    >>> Version('1.alpha')
     <Version('1a0')>

parver keeps the version number in the input form, for example if you 
like a dot before the pre-release tag and prefer 'alpha' to 'a':

    >>> from parver import Version
    >>> v = Version.parse('1.alpha')
    >>> v
     <Version '1.alpha'>

`parver.Version` is immutable, but has methods to derive new versions:

    >>> v.bump_pre()
     <Version '1.alpha1'>
    >>> v = v.replace(pre_tag='beta', pre=0)
    >>> v
     <Version '1.beta0'>
    >>> v.normalize()
     <Version '1b0'>

--
Distutils-SIG mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/distutils-sig.python.org/
Message archived at https://mail.python.org/archives/list/[email protected]/message/DAE6VWGMQX2GAS6F6AQJ5BORB5X46DYN/