[Checkins] SVN: keas.build/trunk/ PYPI-like simple index support when checking package versions
Adam Groszer
agroszer at gmail.com
Wed Dec 9 05:07:30 EST 2009
Log message for revision 106318:
PYPI-like simple index support when checking package versions
Changed:
U keas.build/trunk/CHANGES.txt
U keas.build/trunk/src/keas/build/package.py
-=-
Modified: keas.build/trunk/CHANGES.txt
===================================================================
--- keas.build/trunk/CHANGES.txt 2009-12-09 10:06:41 UTC (rev 106317)
+++ keas.build/trunk/CHANGES.txt 2009-12-09 10:07:30 UTC (rev 106318)
@@ -4,6 +4,8 @@
0.1.7 (unreleased)
------------------
+- Improvement: PYPI-like simple index support when checking package versions
+
- Improvement: Check dependent configs, upload all to the server.
- Improvement: Add ``--force-version`` option.
Modified: keas.build/trunk/src/keas/build/package.py
===================================================================
--- keas.build/trunk/src/keas/build/package.py 2009-12-09 10:06:41 UTC (rev 106317)
+++ keas.build/trunk/src/keas/build/package.py 2009-12-09 10:07:30 UTC (rev 106318)
@@ -118,6 +118,7 @@
if self.options.offline:
logger.info('Offline: Skip looking for versions.')
return []
+
logger.debug('Package Index: ' + self.packageIndexUrl)
req = urllib2.Request(self.packageIndexUrl)
@@ -128,18 +129,45 @@
req.add_header("Authorization", "Basic %s" % base64string)
soup = BeautifulSoup.BeautifulSoup(urllib2.urlopen(req).read())
- #TODO: handle real pypi index page!
- #right now this supports only a flat list of all packages
VERSION = re.compile(self.pkg+r'-(\d+\.\d+(\.\d+){0,2})')
+ simplePageUrl = None
+
versions = []
for tag in soup('a'):
cntnt = str(tag.contents[0]) # str: re does not like non-strings
+
+ if cntnt == self.pkg:
+ try:
+ simplePageUrl = tag['href']
+ except KeyError:
+ pass
+
m = VERSION.search(cntnt)
if m:
versions.append(m.group(1))
+ if len(versions) == 0 and simplePageUrl:
+ #we probably hit a PYPI-like simple index
+ #reload the linked page, check again for versions
+ req = urllib2.Request(simplePageUrl)
+
+ if self.packageIndexUsername:
+ base64string = base64.encodestring(
+ '%s:%s' % (self.packageIndexUsername,
+ self.packageIndexPassword))[:-1]
+ req.add_header("Authorization", "Basic %s" % base64string)
+
+ soup = BeautifulSoup.BeautifulSoup(urllib2.urlopen(req).read())
+
+ for tag in soup('a'):
+ cntnt = str(tag.contents[0]) # str: re does not like non-strings
+
+ m = VERSION.search(cntnt)
+ if m:
+ versions.append(m.group(1))
+
logger.debug('All versions: ' + ' '.join(versions))
# filter versions by ones that came from the branch we are building from.
More information about the checkins
mailing list