[py-svn] r57389 - py/build

hpk at codespeak.net hpk at codespeak.net
Mon Aug 18 10:40:45 CEST 2008


Author: hpk
Date: Mon Aug 18 10:40:45 2008
New Revision: 57389

Added:
   py/build/makebdistegg.py
Log:
a script to remote-control a windows machine and have it make 
two binary eggs for python2.4 and python2.5 automatically


Added: py/build/makebdistegg.py
==============================================================================
--- (empty file)
+++ py/build/makebdistegg.py	Mon Aug 18 10:40:45 2008
@@ -0,0 +1,106 @@
+import py
+import os
+import sys
+
+def trace(*args):
+    print >>sys.stderr, " ".join(map(str, args))
+
+def remote_chdirtemp():
+    #remote_tmpdir = winexec("""
+    #    import os, tempfile
+    #    tmpdir = tempfile.mkdtemp()
+    #    os.chdir(tmpdir)
+    #    channel.send(tmpdir)
+    #""").receive()
+    remote_tmpdir = winexec(r"""
+        import os, tempfile, shutil
+        base = r"C:\tmp\makepyrelease"
+        path = tempfile.mkdtemp(dir=base)
+        #if os.path.exists(path):
+        #    shutil.rmtree(path, ignore_errors=True)
+        #os.mkdir(path)
+        os.chdir(path)
+        channel.send(path) 
+    """).receive()
+    trace("using remote tempdir", remote_tmpdir)
+
+def sendfile(path):
+    channel = winexec("""
+        fn = channel.receive()
+        content = channel.receive()
+        open(fn, 'w').write(content)
+    """)
+    trace("sending", path)
+    channel.send(path.basename)
+    channel.send(path.read())
+
+def remote_checkout(url):
+    channel = winexec("""
+        import os
+        url = channel.receive()
+        errno = os.system("svn co " + url)
+        assert not errno
+    """)
+    channel.send(url)
+    trace("waiting for remote to checkout", url)
+    channel.waitclose()
+
+def remote_cd(path):
+    trace("changing remote curdir to", path)
+    winexec("import os ; os.chdir(%r)" % path).waitclose()
+    
+def remote_makebdist_egg(python="python25"):
+    channel = winexec(r"""
+        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)
+    trace("received result in", logpath)
+
+def remote_getdist():
+    channel = 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
+        print "receiving", basename
+        content = channel.receive()
+        py.path.local(basename).write(content)
+        print "complete"
+
+def winexec(source):
+    return gw.remote_exec(source, stdout=sys.stdout, stderr=sys.stderr)
+
+def main():
+    #errno = os.system("python setup.py sdist")
+    #assert not errno
+    #l = py.path.local("dist").listdir("*.gz")
+    #assert len(l) == 1
+    #sdist = l[0]
+   
+    trace("gateway", gw)
+    wc = py.path.svnwc() 
+    
+    remote_tmpdir = remote_chdirtemp()
+    remote_checkout(wc.info().url)
+    remote_cd(wc.basename)
+    for python in "python24", "python25":
+        remote_makebdist_egg(python)
+    remote_getdist()
+
+if __name__ == '__main__':
+    gw = py.execnet.SocketGateway("10.9.2.62", 8888)
+    try:
+        main()
+    finally:
+        gw.exit() 



More information about the pytest-commit mailing list