comparing version strings?
Hi All, Is there any any in setuptools/distutils/anything else that I can use to compare version strings using the same rules as setuptools? ie: sort the following list of versions: 1.0 2.0dev-r22542-20100623 2.0dev-r22553-20100624 2.0 ...etc cheers, Chris
Hello Chris, See: from distutils.version import StrictVersion and svn://svn.zope.org/repos/main/Sandbox/adamg/zope.wineggbuilder/trunk/src/zope/wineggbuilder/build.py Friday, June 25, 2010, 11:34:59 AM, you wrote: CW> Hi All, CW> Is there any any in setuptools/distutils/anything else that I can use to CW> compare version strings using the same rules as setuptools? CW> ie: sort the following list of versions: CW> 1.0 CW> 2.0dev-r22542-20100623 CW> 2.0dev-r22553-20100624 CW> 2.0 CW> ...etc CW> cheers, CW> Chris CW> _______________________________________________ CW> Distutils-SIG maillist - Distutils-SIG@python.org CW> http://mail.python.org/mailman/listinfo/distutils-sig -- Best regards, Adam GROSZER mailto:agroszer@gmail.com -- Quote of the day: True freedom is frightful
Chris, You also can use the distutils2.version module. I've documented them in my fork [1], waiting to be merged upstream for now, but the codebase of the first (alpha) release of distutils2 [2] ship with the distutils2.version module. This respect version specifiers as described in PEP 354 [3], and I think it's the good way to compare version numbers for the future. Hope it helps, bug reports and/or any feedback is welcome ! Cheers, Alexis [1] http://bitbucket.org/ametaireau/distutils2/src/tip/docs/source/version.rst [2] http://pypi.python.org/pypi/Distutils2/1.0a1 [3] http://www.python.org/dev/peps/pep-0345/#version-specifiers On Fri, Jun 25, 2010 at 11:43 AM, Adam GROSZER <agroszer@gmail.com> wrote:
Hello Chris,
See: from distutils.version import StrictVersion
and
svn:// svn.zope.org/repos/main/Sandbox/adamg/zope.wineggbuilder/trunk/src/zope/wineggbuilder/build.py
Friday, June 25, 2010, 11:34:59 AM, you wrote:
CW> Hi All,
CW> Is there any any in setuptools/distutils/anything else that I can use to CW> compare version strings using the same rules as setuptools?
CW> ie: sort the following list of versions:
CW> 1.0 CW> 2.0dev-r22542-20100623 CW> 2.0dev-r22553-20100624 CW> 2.0
CW> ...etc
CW> cheers,
CW> Chris
CW> _______________________________________________ CW> Distutils-SIG maillist - Distutils-SIG@python.org CW> http://mail.python.org/mailman/listinfo/distutils-sig
-- Best regards, Adam GROSZER mailto:agroszer@gmail.com -- Quote of the day: True freedom is frightful
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
-- Alexis
Alexis Métaireau wrote:
Chris,
You also can use the distutils2.version module. I've documented them in my fork [1], waiting to be merged upstream for now, but the codebase of the first (alpha) release of distutils2 [2] ship with the distutils2.version module.
Yes, this is good, but since we're using setuptools, I *really* want to compare versions in exactly the same way that it does, for better or worse... I guess I need to go and read the setuptools source, unless anyone has some easy answers for me? cheers, Chris -- Simplistix - Content Management, Batch Processing & Python Consulting - http://www.simplistix.co.uk
At 10:34 AM 6/25/2010 +0100, Chris Withers wrote:
Hi All,
Is there any any in setuptools/distutils/anything else that I can use to compare version strings using the same rules as setuptools?
ie: sort the following list of versions:
1.0 2.0dev-r22542-20100623 2.0dev-r22553-20100624 2.0
...etc
http://peak.telecommunity.com/DevCenter/PkgResources#parsing-utilities from pkg_resources import parse_version sort(versions, key=parse_version)
cheers,
Chris
_______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org http://mail.python.org/mailman/listinfo/distutils-sig
participants (4)
-
Adam GROSZER
-
Alexis Métaireau
-
Chris Withers
-
P.J. Eby