Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
use distutils.version.StrictVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Jun 18, 2010
1 parent 6a8b3e0 commit 01e250d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
11 changes: 10 additions & 1 deletion src/zope/wineggbuilder/README.txt
Expand Up @@ -28,9 +28,14 @@ Let's see:
INFO - Starting to build
INFO - Processing zope.proxy [zope.proxy_34_to_35]
DEBUG - getting http://pypi.python.org/simple/zope.proxy/
DEBUG - Got a file: zope.proxy-3.5.0-py2.6-win-amd64.egg
DEBUG - Got a file: zope.proxy-3.5.0-py2.6-win32.egg
DEBUG - Got a file: zope.proxy-3.4.0-py2.4-win32.egg
DEBUG - Got a file: zope.proxy-3.4.0.tar.gz
DEBUG - Got a file: zope.proxy-3.5.0-py2.5-win32.egg
DEBUG - Got a file: zope.proxy-3.5.0.tar.gz
DEBUG - Got a file: zope.proxy-3.4.2.zip
DEBUG - Got a file: zope.proxy-3.5.0-py2.4-win32.egg
DEBUG - Got a file: zope.proxy-3.4.2-py2.6-win32.egg
DEBUG - Got a file: zope.proxy-3.4.1-py2.4-win32.egg
DEBUG - Got a file: zope.proxy-3.4.1.zip
Expand Down Expand Up @@ -267,6 +272,10 @@ Let's see:
DEBUG - Build not required for [zope.proxy_34_to_35] zope.proxy 3.4.2 py25_32
DEBUG - Checking if build required for [zope.proxy_34_to_35] zope.proxy 3.4.2 py26_32
DEBUG - Build not required for [zope.proxy_34_to_35] zope.proxy 3.4.2 py26_32
DEBUG - Checking if build required for [zope.proxy_34_to_35] zope.proxy 3.5.0 py25_32
DEBUG - Build not required for [zope.proxy_34_to_35] zope.proxy 3.5.0 py25_32
DEBUG - Checking if build required for [zope.proxy_34_to_35] zope.proxy 3.5.0 py26_32
DEBUG - Build not required for [zope.proxy_34_to_35] zope.proxy 3.5.0 py26_32
INFO - Done.
INFO -
<BLANKLINE>
Expand All @@ -277,7 +286,7 @@ Let's see:
3.4.0 n/a existed done n/a
3.4.1 n/a done failed n/a
3.4.2 n/a existed existed n/a
3.5.0 n/a n/a n/a n/a
3.5.0 n/a existed existed n/a
3.6.0 n/a n/a n/a n/a

Let's see what was executed on mocks:
Expand Down
38 changes: 19 additions & 19 deletions src/zope/wineggbuilder/build.py
Expand Up @@ -20,6 +20,7 @@

import BeautifulSoup
import ConfigParser
from distutils.version import StrictVersion

from zope.wineggbuilder import base

Expand Down Expand Up @@ -111,19 +112,6 @@ def build(self, package, version, files, sourceFolder, status):
if tmpfile:
os.remove(tmpfile)

def versionToTuple(version):
#tries to do "3.4.0" -> ('0003','0004','0000')
#otherwise the problem starts with 3.10.0, that would be less than 3.4.0
#problems arise on the last digit when it has 'dev' or 'b'
parts = []
for p in version.split('.'):
try:
# we try our best to convert to a comparable number
parts.append("%04d" % int(p))
except ValueError:
parts.append(p)
return tuple(parts)

class Package(object):
#hook to enable testing
pypiKlass = base.PYPI
Expand Down Expand Up @@ -160,14 +148,26 @@ def build(self, status):

#1.1 filter versions according to minVersion and maxVersion:
if self.minVersion:
minver = versionToTuple(self.minVersion)
versions = [v for v in versions
if versionToTuple(v) >= minver]
minver = StrictVersion(self.minVersion)
ov = []
for v in versions:
try:
if StrictVersion(v) >= minver:
ov.append(v)
except ValueError:
pass
versions = ov

if self.maxVersion:
maxver = versionToTuple(self.maxVersion)
versions = [v for v in versions
if versionToTuple(v) <= maxver]
maxver = StrictVersion(self.maxVersion)
ov = []
for v in versions:
try:
if StrictVersion(v) <= maxver:
ov.append(v)
except ValueError:
pass
versions = ov

versions.sort()
if len(versions) == 0:
Expand Down

0 comments on commit 01e250d

Please sign in to comment.