[py-svn] r57436 - py/build

hpk at codespeak.net hpk at codespeak.net
Mon Aug 18 18:16:16 CEST 2008


Author: hpk
Date: Mon Aug 18 18:16:15 2008
New Revision: 57436

Added:
   py/build/update_website.py
      - copied unchanged from r57370, py/build/_update_website.py
Removed:
   py/build/_update_website.py
Modified:
   py/build/gensetup.py
   py/build/makebdistegg.py
Log:
fixes to build scripts, 
rename update_website script


Deleted: /py/build/_update_website.py
==============================================================================
--- /py/build/_update_website.py	Mon Aug 18 18:16:15 2008
+++ (empty file)
@@ -1,89 +0,0 @@
-#!/usr/bin/env python
-
-""" run py.test with the --apigen option and rsync the results to a host
-
-    rsyncs the whole package (with all the ReST docs converted to HTML) as well
-    as the apigen docs to a given remote host and path
-"""
-import _fixpythonpath
-import py
-import sys
-
-def rsync(pkgpath, apidocspath, gateway, remotepath):
-    """ copy the code and docs to the remote host """
-    # copy to a temp dir first, even though both paths (normally) share the
-    # same parent dir, that may contain other stuff that we don't want to
-    # copy...
-    tempdir = py.test.ensuretemp('update_website_rsync_temp')
-    pkgpath.copy(tempdir.ensure(pkgpath.basename, dir=True))
-    apidocspath.copy(tempdir.ensure(apidocspath.basename, dir=True))
-
-    rs = py.execnet.RSync(tempdir)
-    rs.add_target(gateway, remotepath, delete=True)
-    rs.send()
-
-def run_tests(pkgpath, apigenpath, args='', captureouterr=False):
-    """ run the unit tests and build the docs """
-    pypath = py.__pkg__.getpath()
-    pytestpath = pypath.join('bin/py.test')
-    # XXX this would need a Windows specific version if we want to allow
-    # running this script on that platform, but currently --apigen doesn't
-    # work there anyway...
-    apigenscript = pkgpath.join('apigen/apigen.py') # XXX be more general here?
-    if not apigenscript.check(file=True):
-        apigenscript = pypath.join('apigen/apigen.py')
-    cmd = ('APIGENPATH="%s" PYTHONPATH="%s:%s" python '
-           '"%s" %s --apigen="%s" "%s"' % (apigenpath, pypath.dirpath(),
-                                           pkgpath.dirpath(), pytestpath,
-                                           args, apigenscript,
-                                           pkgpath))
-    if captureouterr:
-        cmd += ' > /dev/null 2>&1'
-    try:
-        output = py.process.cmdexec(cmd)
-    except py.error.Error, e:
-        return e.err or str(e)
-    return None
-
-def main(pkgpath, apidocspath, rhost, rpath, args='', ignorefail=False):
-    print 'running tests'
-    errors = run_tests(pkgpath, apidocspath, args)
-    if errors:
-        print >>sys.stderr, \
-              'Errors while running the unit tests: %s' % (errors,)
-        if not ignorefail:
-            print >>sys.stderr, ('if you want to continue the update '
-                                 'regardless of failures, use --ignorefail')
-            sys.exit(1)
-    
-    print 'rsyncing'
-    gateway = py.execnet.SshGateway(rhost)
-    errors = rsync(pkgpath, apidocspath, gateway, rpath)
-    if errors:
-        print >>sys.stderr, 'Errors while rsyncing: %s'
-        sys.exit(1)
-
-if __name__ == '__main__':
-    args = sys.argv[1:]
-    if '--help' in args or '-h' in args:
-        print 'usage: %s [options]'
-        print
-        print 'run the py lib tests and update the py lib website'
-        print 'options:'
-        print '    --ignorefail: ignore errors in the unit tests and always'
-        print '                  try to rsync'
-        print '    --help: show this message'
-        print
-        print 'any additional arguments are passed on as-is to the py.test'
-        print 'child process'
-        sys.exit()
-    ignorefail = False
-    if '--ignorefail' in args:
-        args.remove('--ignorefail')
-        ignorefail = True
-    args = ' '.join(sys.argv[1:])
-    pkgpath = py.__pkg__.getpath()
-    apidocspath = pkgpath.dirpath().join('apigen')
-    main(pkgpath, apidocspath, 'codespeak.net',
-         '/home/guido/rsynctests', args, ignorefail)
-

Modified: py/build/gensetup.py
==============================================================================
--- py/build/gensetup.py	(original)
+++ py/build/gensetup.py	Mon Aug 18 18:16:15 2008
@@ -42,7 +42,6 @@
             if line.strip():
                 assert not line[:indent].strip(), line
                 line = line[indent:]
-            print line
             self.lines.append(line)
 
     def write_winfuncs(self):
@@ -51,9 +50,9 @@
 
 
     def setup_header(self):
-        tooltime = "%s %s" %(py.std.time.asctime(), py.std.time.tzname[0])
+        #tooltime = "%s %s" %(py.std.time.asctime(), py.std.time.tzname[0])
         toolname = toolpath.basename 
-        toolrevision = py.path.svnwc(toolpath).info().rev 
+        #toolrevision = py.path.svnwc(toolpath).info().rev 
         
         pkgname = self.pkg.__name__
         url = self.wcinfo.url
@@ -64,7 +63,7 @@
 
                     %(url)s, revision=%(rev)s
 
-                autogenerated by %(toolname)s, %(toolrevision)s, %(tooltime)s
+                autogenerated by %(toolname)s
             """
             import os, sys
         ''' % locals())
@@ -90,7 +89,7 @@
         #params['url'] = self.wcinfo.url 
         #params['rev'] = self.wcinfo.rev 
         params['long_description'] = reformat(params['long_description'])
-        print py.std.pprint.pprint(params)
+        #print py.std.pprint.pprint(params)
         self.append('''
             def main():
                 setup(cmdclass=cmdclass,
@@ -119,7 +118,6 @@
             self.append_pprint(indent, zip_safe=False)
         self.lines.append(indent[4:] + ")\n")
 
-
     def append_pprint(self, indent, **kw):
         for name, value in kw.items():
             stringio = py.std.StringIO.StringIO()
@@ -154,7 +152,8 @@
         datafiles = []
         pkgbase = self.wcbasedir.join(self.pkg.__name__)
         for p in self.allpaths:
-            if p.check(file=1) and not p.ext == ".py":
+            if p.check(file=1) and (not p.dirpath("__init__.py").check() 
+               or p.ext != ".py"):
                 if p.dirpath() != self.wcbasedir:
                     datafiles.append(p.relto(pkgbase))
         return {'py': datafiles}
@@ -224,7 +223,7 @@
         for p in self.allpaths:
             if p.check(dir=1):
                 continue
-            toadd = p.relto(wcbasedir)
+            toadd = p.relto(self.wcbasedir)
             if toadd and toadd not in self.EXCLUDES:
                 lines.append("%s" %(toadd))
         targetfile = self.basedir.join("MANIFEST")
@@ -235,7 +234,7 @@
         self.write_manifest()
         self.write_setup()
 
-if __name__ == "__main__":
+def parseargs():
     basedir = py.path.local(sys.argv[1])
     if not basedir.check():
         error("basedir not found: %s" %(basedir,))
@@ -248,6 +247,14 @@
     wcbasedir = py.path.svnwc(basedir)
     if not wcbasedir.check(versioned=True):
         error("not a svn working copy:%s" % basedir)
-    
+    return basedir
+
+def main(basedir=None):
+    if basedir is None:
+        basedir = parseargs()
+    wcbasedir = py.path.svnwc(basedir)
     writer = SetupWriter(wcbasedir, py, setuptools=True)
     writer.write_all()
+
+if __name__ == "__main__":
+    main()

Modified: py/build/makebdistegg.py
==============================================================================
--- py/build/makebdistegg.py	(original)
+++ py/build/makebdistegg.py	Mon Aug 18 18:16:15 2008
@@ -2,6 +2,10 @@
 import os
 import sys
 
+mydir = py.magic.autopath().dirpath()
+gensetuppath = mydir.join("gensetup.py")
+assert gensetuppath.check()
+
 def trace(*args):
     print >>sys.stderr, " ".join(map(str, args))
 
@@ -81,6 +85,10 @@
 def winexec(source):
     return gw.remote_exec(source, stdout=sys.stdout, stderr=sys.stderr)
 
+def sysexec(cmd):
+    print "executing", cmd
+    os.system(cmd)
+
 def main():
     #errno = os.system("python setup.py sdist")
     #assert not errno
@@ -88,8 +96,12 @@
     #assert len(l) == 1
     #sdist = l[0]
    
-    trace("gateway", gw)
     wc = py.path.svnwc() 
+    #trace("regenerating setup")
+    #sysexec("python %s %s" %(gensetuppath, py.path.local()))
+    #wc.commit("auto-commit for building new eggs")
+
+    trace("gateway", gw)
     
     remote_tmpdir = remote_chdirtemp()
     remote_checkout(wc.info().url)



More information about the pytest-commit mailing list