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

Commit

Permalink
trying git support, first with BTrees
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Groszer committed Jan 21, 2013
1 parent 89c087a commit bf8826b
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 26 deletions.
5 changes: 4 additions & 1 deletion rackspace.ini
Expand Up @@ -67,11 +67,14 @@ excludeVersions = 3.10.4
tagurl = svn://svn.zope.org/repos/main/ZODB/tags/

[BTrees]
# versions before 4.0.4 were SVN based
package = BTrees
minVersion =
minVersion = 4.0.4
maxVersion =
excludeVersions = 4.0.0
targets = py26_32 py26_64 py27_32 py27_64
repotype = git
#repourl = https://github.com/zopefoundation/BTrees.git

[persistent]
package = persistent
Expand Down
20 changes: 14 additions & 6 deletions src/zope/wineggbuilder/base.py
Expand Up @@ -14,19 +14,14 @@
"""base classes
"""
__docformat__ = 'ReStructuredText'
import StringIO
import base64
import httplib
import logging
import optparse
import os
import pkg_resources
import shutil
import subprocess
import sys
import stat
import urllib2
import urlparse
import xmlrpclib

LOGGER = logging.Logger('build')
Expand Down Expand Up @@ -66,8 +61,21 @@ def do(self, cmd):
LOGGER.debug('Output: \n%s' % stdout)
return stdout

class SVN(object):

class Git(object):
def __init__(self, exitOnError=True):
self.cmd = self.commandKlass(exitOnError=exitOnError)

def clone(self, url, folder):
command = 'git clone %s %s' % (url, folder)
return self.cmd.do(command)

def checkout(self, branch):
command = 'git checkout %s' % branch
return self.cmd.do(command)


class SVN(object):
user = None
passwd = None
forceAuth = False
Expand Down
45 changes: 26 additions & 19 deletions src/zope/wineggbuilder/build.py
Expand Up @@ -14,19 +14,11 @@
"""Main builder stuff
"""
__docformat__ = 'ReStructuredText'
import StringIO
import base64
import httplib
import logging
import optparse
import os
import pkg_resources
import re
import subprocess
import sys
import tempfile
import urllib2
import urlparse
from collections import defaultdict

import BeautifulSoup
Expand All @@ -37,6 +29,7 @@

LOGGER = base.LOGGER


def getOption(config, section, name, default=None):
try:
return config.get(section, name)
Expand Down Expand Up @@ -128,6 +121,7 @@ class Package(object):
pypiKlass = base.PYPI
urlGetterKlass = base.URLGetter
svnKlass = base.SVN
gitKlass = base.Git

def __init__(self, sectionName, config, options, compilers):
self.sectionName = sectionName
Expand All @@ -138,15 +132,22 @@ def read(self, sectionName, config, compilers):
self.name = config.get(sectionName, 'package')
self.pypiurl = getOption(config, sectionName, 'pypiurl',
'http://pypi.python.org/simple/%s/' % self.name)
self.tagurl = getOption(config, sectionName, 'tagurl',
'svn://svn.zope.org/repos/main/%s/tags' % self.name)
if self.tagurl.endswith('/'):
self.tagurl = self.tagurl[:-1]
self.repotype = getOption(config, sectionName, 'repotype', 'svn')
if self.repotype == 'svn':
self.tagurl = getOption(config, sectionName, 'tagurl',
'svn://svn.zope.org/repos/main/%s/tags' % self.name)
if self.tagurl.endswith('/'):
self.tagurl = self.tagurl[:-1]
if self.repotype == 'git':
self.repourl = getOption(config, sectionName, 'repourl',
'https://github.com/zopefoundation/%s.git' % self.name)
if self.repourl.endswith('/'):
self.repourl = self.repourl[:-1]
self.minVersion = getOption(config, sectionName, 'minVersion')
self.maxVersion = getOption(config, sectionName, 'maxVersion')
self.needSource = bool(getOption(config, sectionName, 'needSource', 'True'))
self.excludeVersions = getOption(
config, sectionName, 'excludeVersions' ,'').split()
config, sectionName, 'excludeVersions', '').split()
self.targets = []
for target in config.get(sectionName, 'targets').split():
self.targets.append(compilers[target])
Expand Down Expand Up @@ -198,7 +199,7 @@ def build(self, status):
verFiles = defaultdict(list)
simple = self.urlGetterKlass().get(self.pypiurl)
soup = BeautifulSoup.BeautifulSoup(simple)
VERSION = re.compile(self.name+r'-(\d+\.\d+(\.\d+\w*){0,2})')
VERSION = re.compile(self.name + r'-(\d+\.\d+(\.\d+\w*){0,2})')
gotSource = False

for tag in soup('a'):
Expand All @@ -220,7 +221,6 @@ def build(self, status):
if self.needSource and not gotSource:
LOGGER.info("No source release (.zip/.tar.gz/.tgz) found")

svn = self.svnKlass(exitOnError=False)
for version in versions:
#3 check whether we need a build
needs = []
Expand All @@ -236,11 +236,17 @@ def build(self, status):
tmpfolder = tempfile.mkdtemp('wineggbuilder')
try:
try:
#3.1 svn co tag
svnurl = "%s/%s" % (self.tagurl, version)
svn.co(svnurl, tmpfolder)
if self.repotype == 'svn':
#3.1 svn co tag
svn = self.svnKlass(exitOnError=False)
svnurl = "%s/%s" % (self.tagurl, version)
svn.co(svnurl, tmpfolder)
if self.repotype == 'git':
git = self.gitKlass(exitOnError=False)
git.clone(self.repourl, tmpfolder)
git.checkout(version)
except OSError:
status.setStatus(self, version, "SVN error")
status.setStatus(self, version, "SVN/Git error")
else:
#3.2 build missing
for target in needs:
Expand All @@ -251,6 +257,7 @@ def build(self, status):
#3.3 del temp folder
base.rmtree(tmpfolder)


class Status(object):
def __init__(self, packages, targets):
self.data = {}
Expand Down

0 comments on commit bf8826b

Please sign in to comment.