import py import os import sys mydir = py.magic.autopath().dirpath() gensetuppath = mydir.join("gensetup.py") assert gensetuppath.check() class BDistEggMaker: def __init__(self, xspec): self.xspec = xspec self.gw = py.execnet.makegateway(xspec) self.trace("instantiated %r -> %s" %(self.xspec, self.gw)) rinfo = self.gw._rinfo() self.trace("remote", rinfo) def trace(self, *args): print >>sys.stdout, " ".join(map(str, args)) def remote_checkout(self, url): self.trace("checking out", url) channel = self.winexec(""" import os url = channel.receive() errno = os.system("svn co " + str(url)) assert not errno """) channel.send(url) self.trace("waiting for remote to checkout", url) channel.waitclose() def remote_cd(self, path): self.trace("changing remote curdir to", path) self.winexec("import os ; os.chdir(%r)" % path).waitclose() def remote_makebdist_egg(self, python="python25"): channel = self.winexec(r""" import py import os errno = os.system(r"C:\%s\python setup.py bdist_egg >log") channel.send(open('log').read()) assert not errno """ % python) log = channel.receive() logpath = py.path.local("bdist_egg_%s.log" % python) logpath.write(log) self.trace("received log file in", logpath) def remote_getdist(self): channel = self.winexec(r""" import py for p in py.path.local("dist").listdir("*.egg"): channel.send(p.basename) channel.send(p.read()) channel.send(None) """) while 1: basename = channel.receive() if basename is None: break self.trace("receiving", basename) content = channel.receive() py.path.local("dist").ensure(basename).write(content) self.trace("complete") def winexec(self, source): return self.gw.remote_exec(source, stdout=sys.stdout, stderr=sys.stderr) def main(self, wc): wc = py.path.svnwc(wc) if not wc.check(): raise IOError("not found: %s" % wc) assert wc.join("py").check(), wc self.remote_checkout(wc.info().url) self.remote_cd(wc.basename) for python in "python24", "python25": self.remote_makebdist_egg(python) self.remote_getdist() #self.trace("regenerating setup") #sysexec("python %s %s" %(gensetuppath, py.path.local())) #wc.commit("auto-commit for building new eggs") def sysexec(cmd): print "executing", cmd os.system(cmd) if __name__ == '__main__': xspec, basepath = sys.argv[1:] pypath = py.path.local(basepath).join("py") if not pypath.check(): raise ValueError("not exists: %s" % pypath) wc = py.path.svnwc(pypath.dirpath()) maker = BDistEggMaker(xspec) maker.main(wc)