From 013cbb52a10c1a06a2e084c75bba90b7d0b0b44d Mon Sep 17 00:00:00 2001 From: hpk Date: Sun, 17 Aug 2008 17:24:29 +0200 Subject: [PATCH] [svn r57358] move more scripts to build directory --HG-- branch : trunk --- py/bin/_docgen.py | 58 ----------- py/bin/_makepyrelease.py | 184 ----------------------------------- py/bin/_update_website.py | 89 ----------------- py/bin/pytest.cmd | 3 - py/bin/win32/py.cleanup.cmd | 2 - py/bin/win32/py.countloc.cmd | 2 - py/bin/win32/py.lookup.cmd | 2 - py/bin/win32/py.rest.cmd | 2 - py/bin/win32/py.test.cmd | 2 - 9 files changed, 344 deletions(-) delete mode 100755 py/bin/_docgen.py delete mode 100755 py/bin/_makepyrelease.py delete mode 100755 py/bin/_update_website.py delete mode 100644 py/bin/pytest.cmd delete mode 100644 py/bin/win32/py.cleanup.cmd delete mode 100644 py/bin/win32/py.countloc.cmd delete mode 100644 py/bin/win32/py.lookup.cmd delete mode 100644 py/bin/win32/py.rest.cmd delete mode 100644 py/bin/win32/py.test.cmd diff --git a/py/bin/_docgen.py b/py/bin/_docgen.py deleted file mode 100755 index ebd06f2f1..000000000 --- a/py/bin/_docgen.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python - -""" quick tool to get documentation + apigen docs generated - - given a certain targetpath, apigen docs will be placed in 'apigen', - - user can choose to only build either docs or apigen docs: in this case, - the navigation bar will be adjusted -""" - -from _findpy import py -import py -pypath = py.__pkg__.getpath() - -def run_tests(path, envvars='', args=''): - pytestpath = pypath.join('bin/py.test') - cmd = ('PYTHONPATH="%s" %s python "%s" %s "%s"' % - (pypath.dirpath(), envvars, pytestpath, args, path)) - print cmd - py.process.cmdexec(cmd) - -def build_apigen_docs(targetpath, testargs=''): - run_tests(pypath, - 'APIGEN_TARGET="%s/apigen" APIGEN_DOCRELPATH="../"' % ( - targetpath,), - '%s --apigen="%s/apigen/apigen.py"' % (testargs, pypath)) - -def build_docs(targetpath, testargs): - docpath = pypath.join('doc') - run_tests(docpath, '', - testargs + ' --forcegen --apigen="%s/apigen/apigen.py"' % (pypath,)) - docpath.copy(targetpath) - -def build_nav(targetpath, docs=True, api=True): - pass - -def build(targetpath, docs=True, api=True, testargs=''): - targetpath.ensure(dir=True) - if docs: - print 'building docs' - build_docs(targetpath, testargs) - if api: - print 'building api' - build_apigen_docs(targetpath, testargs) - -if __name__ == '__main__': - import sys - if len(sys.argv) == 1: - print 'usage: %s [options]' - print - print ' targetdir: a path to a directory (created if it doesn\'t' - print ' exist) where the docs are put' - print ' options: options passed to py.test when running the tests' - sys.exit(1) - targetpath = py.path.local(sys.argv[1]) - args = ' '.join(sys.argv[2:]) - build(targetpath, True, True, args) - diff --git a/py/bin/_makepyrelease.py b/py/bin/_makepyrelease.py deleted file mode 100755 index 80b99ed0f..000000000 --- a/py/bin/_makepyrelease.py +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env python - -from _findpy import py -import sys - -pydir = py.path.local(py.__file__).dirpath() -rootdir = pydir.dirpath() - -def gen_manifest(): - pywc = py.path.svnwc(pydir) - status = pywc.status(rec=True) - #assert not status.modified - #assert not status.deleted - #assert not status.added - versioned = dict([(x.localpath,1) for x in status.allpath()]) - - l = [] - for x in rootdir.visit(None, lambda x: x.basename != '.svn'): - if x.check(file=1): - names = [y.basename for y in x.parts()] - if '.svn' in names: - l.append(x) - elif x in versioned: - l.append(x) - l.append(rootdir / "setup.py") - l = [x.relto(rootdir) for x in l] - l.append("") - s = "\n".join(l) - return s - -def trace(arg): - lines = str(arg).split('\n') - prefix = "[trace] " - prefix = "* " - indent = len(prefix) - ispace = " " * indent - lines = [ispace + line for line in lines] - if lines: - lines[0] = prefix + lines[0][indent:] - for line in lines: - print >>py.std.sys.stdout, line - -def make_distfiles(tmpdir): - """ return distdir with tar.gz and zipfile. """ - manifest = tmpdir.join('MANIFEST') - trace("generating %s" %(manifest,)) - content = gen_manifest() - manifest.write(content) - trace("wrote %d files into manifest file" %len(content.split('\n'))) - - distdir = tmpdir.ensure('dist', dir=1) - oldir = rootdir.chdir() - try: - from py.__.misc._dist import setup - trace("invoking sdist, generating into %s" % (distdir,)) - setup(py, script_name="setup.py", - script_args=('-q', 'sdist', '--no-prune', - '-m', str(manifest), - '--formats=gztar,zip', - '-d', str(distdir))) - setup(py, script_name="setup.py", - script_args=('-q', 'bdist_wininst', - #'-m', str(manifest), - '-d', str(distdir))) - finally: - oldir.chdir() - return distdir - - -def pytest(unpacked): - trace("py-testing %s" % unpacked) - old = unpacked.chdir() - try: - import os - os.system("python py/bin/py.test py") - finally: - old.chdir() - -def unpackremotetar(tmpdir, strurl): - import tarfile, urllib - f = urllib.urlopen(strurl) - basename = strurl.split('/')[-1] - target = tmpdir.join(basename) - trace("downloading %r to %s" %(strurl, target,)) - target.write(f.read()) - - trace("extracting to %s" %(target,)) - old = tmpdir.chdir() - try: - py.process.cmdexec("tar zxf %s" %(target,)) - finally: - old.chdir() - prefix = '.tar.gz' - assert basename.endswith(prefix) - stripped = basename[:-len(prefix)] - unpacked = tmpdir.join(stripped) - assert unpacked - return unpacked - -def checksvnworks(unpacked): - pywc = py.path.svnwc(unpacked.join('py')) - trace("checking versioning works: %s" %(pywc,)) - status = pywc.status(rec=True) - assert not status.modified - assert not status.deleted - assert not status.unknown - -def pytest_remote(address, url): - gw = py.execnet.SshGateway(address) - basename = url[url.rfind('/')+1:] - purebasename = basename[:-len('.tar.gz')] - - def mytrace(x, l=[]): - l.append(x) - if x.endswith('\n'): - trace("".join(l)) - l[:] = [] - - channel = gw.remote_exec(stdout=mytrace, stderr=sys.stderr, source=""" - url = %(url)r - basename = %(basename)r - purebasename = %(purebasename)r - import os, urllib - f = urllib.urlopen(url) - print "reading from", url - s = f.read() - f.close() - f = open(basename, 'w') - f.write(s) - f.close() - if os.path.exists(purebasename): - import shutil - shutil.rmtree(purebasename) - os.system("tar zxf %%s" %% (basename,)) - print "unpacked", purebasename - os.chdir(purebasename) - print "testing at %(address)s ..." - #os.system("python py/bin/py.test py") - import commands - status, output = commands.getstatusoutput("python py/bin/py.test py") - #print output - print "status:", status - - """ % locals()) - channel.waitclose(200.0) - -if __name__ == '__main__': - py.magic.invoke(assertion=True) - version = py.std.sys.argv[1] - assert py.__pkg__.version == version, ( - "py package has version %s\nlocation: %s" % - (py.__pkg__.version, pydir)) - - tmpdir = py.path.local.get_temproot().join('makepyrelease-%s' % version) - if tmpdir.check(): - trace("removing %s" %(tmpdir,)) - tmpdir.remove() - tmpdir.mkdir() - trace("using tmpdir %s" %(tmpdir,)) - - distdir = make_distfiles(tmpdir) - targz = distdir.join('py-%s.tar.gz' % version) - zip = distdir.join('py-%s.zip' % version) - files = distdir.listdir() - for fn in files: - assert fn.check(file=1) - - remotedir = 'codespeak.net://www/codespeak.net/htdocs/download/py/' - source = distdir # " ".join([str(x) for x in files]) - trace("rsyncing %(source)s to %(remotedir)s" % locals()) - py.process.cmdexec("rsync -avz %(source)s/ %(remotedir)s" % locals()) - - ddir = tmpdir.ensure('download', dir=1) - URL = py.__pkg__.download_url # 'http://codespeak.net/download/py/' - unpacked = unpackremotetar(ddir, URL) - assert unpacked == ddir.join("py-%s" % (version,)) - - #checksvnworks(unpacked) - #pytest(unpacked) - - pytest_remote('test@codespeak.net', py.__pkg__.download_url) - - - diff --git a/py/bin/_update_website.py b/py/bin/_update_website.py deleted file mode 100755 index c24c8f904..000000000 --- a/py/bin/_update_website.py +++ /dev/null @@ -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 -""" -from _findpy import py -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) - diff --git a/py/bin/pytest.cmd b/py/bin/pytest.cmd deleted file mode 100644 index a622942ea..000000000 --- a/py/bin/pytest.cmd +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -python "%~dp0\py.test" %* - diff --git a/py/bin/win32/py.cleanup.cmd b/py/bin/win32/py.cleanup.cmd deleted file mode 100644 index 4cf0eae86..000000000 --- a/py/bin/win32/py.cleanup.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -python "%~dp0\..\py.cleanup" %* diff --git a/py/bin/win32/py.countloc.cmd b/py/bin/win32/py.countloc.cmd deleted file mode 100644 index a7a042894..000000000 --- a/py/bin/win32/py.countloc.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -python "%~dp0\..\py.countloc" %* diff --git a/py/bin/win32/py.lookup.cmd b/py/bin/win32/py.lookup.cmd deleted file mode 100644 index a0ad5e0f4..000000000 --- a/py/bin/win32/py.lookup.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -python "%~dp0\..\py.lookup" %* diff --git a/py/bin/win32/py.rest.cmd b/py/bin/win32/py.rest.cmd deleted file mode 100644 index 004ff09a6..000000000 --- a/py/bin/win32/py.rest.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -python "%~dp0\..\py.rest" %* diff --git a/py/bin/win32/py.test.cmd b/py/bin/win32/py.test.cmd deleted file mode 100644 index 51d78e330..000000000 --- a/py/bin/win32/py.test.cmd +++ /dev/null @@ -1,2 +0,0 @@ -@echo off -python "%~dp0\..\py.test" %*