Ronald Oussoren avatar Ronald Oussoren committed 61acd5d

Merged revisions 2554-2555 via svnmerge from
https://svn.red-bean.com/pyobjc/trunk/pyobjc

........
r2554 | ronaldoussoren | 2010-07-29 20:52:34 +0200 (Thu, 29 Jul 2010) | 3 lines

* run_tests: add option to only run the initial setup
* release: new script to publish a new release
........
r2555 | ronaldoussoren | 2010-07-29 20:53:25 +0200 (Thu, 29 Jul 2010) | 2 lines

Fix typo in pyobjc_setup.py, needed to reliably build
........

Comments (0)

Files changed (38)

build-support/release.py

+#!/usr/bin/env python3
+# TODO: 
+# - create and upload eggs for 'intel' builds of 2.7 and 3.2
+# - create and upload documentation (to packages.python.org)
+# - sign release files using gpg (distutils has support, need to find a way
+#   to avoid typing password dozens of times)
+import getopt
+import subprocess
+import shutil
+import os
+import sys
+from topsort import topological_sort
+
+
+gUsage="""\
+    release.py --all
+or
+    release.py package...
+"""
+
+gTopDir = os.path.dirname(
+        os.path.dirname(
+            os.path.abspath(__file__)))
+
+def main():
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'h?',
+                ['all', 'help', 'identity='])
+    except getopt.error as msg:
+        print(msg, file=sys.stderr)
+        print(gUsage, file=sys.stderr)
+        sys.exit(1)
+
+    all=False
+    packages = args
+    identity = 'ronaldoussoren@mac.com'
+    upload = ['upload',]
+
+    for k, v in opts:
+        if k in ('-h', '-?', '--help'):
+            print(gUsage)
+            sys.exit(0)
+
+        elif k in ('--all',):
+            all=True
+
+        elif k in ('--identity',):
+            identity = v
+
+        elif k in ('--no-upload',):
+            upload = []
+
+        elif k in ('--upload',):
+            upload = ['upload',]
+
+        else:
+            raise ValueError("Unhandled option: %s"%(k,))
+
+    if all and packages:
+        print("Specify either --all or a list of packages", file=sys.stderr)
+        sys.exit(1)
+
+    if not all and not packages:
+        print("Specify either --all or a list of packages", file=sys.stderr)
+        sys.exit(1)
+
+    if all:
+        packages = [ 'pyobjc-core' ] 
+        packages += detect_frameworks()
+        packages += ['pyobjc']
+
+    for pkg in packages:
+        print("== ", pkg)
+        srcdir = os.path.join(gTopDir, pkg)
+        if not os.path.exists(srcdir):
+            print("No such package:", srcdir, file=sys.stderr)
+            continue
+
+        if os.path.exists(os.path.join(srcdir, 'build')):
+            shutil.rmtree(os.path.join(srcdir, 'build'))
+
+        if os.path.exists(os.path.join(srcdir, 'dist')):
+            shutil.rmtree(os.path.join(srcdir, 'dist'))
+
+        print(" - sdist")
+        p = subprocess.Popen(
+            ['python2.7', 'setup.py', 'sdist', ] + upload,
+                # 'upload', '--sign', '--identity',  identity ],
+            cwd=srcdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+        lines, _ = p.communicate()
+        exit = p.wait()
+
+        if exit != 0:
+            print(lines.decode('utf-8'))
+            print("Creating or uploading sdist failed")
+            sys.exit(1)
+
+        for python in ('python2.6', 'python2.7', 'python3.1', 'python3.2'):
+            print(" -", python)
+
+            # Force removal of 'build', I ran into 2to3 issues for some python
+            # versions.
+            if os.path.exists(os.path.join(srcdir, 'build')):
+                shutil.rmtree(os.path.join(srcdir, 'build'))
+
+            p = subprocess.Popen(
+                [python, 'setup.py', 'bdist_egg', ] + upload,
+                    # 'upload', '--sign', '--identity',  identity ],
+                cwd=srcdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+            lines, _ = p.communicate()
+            exit = p.wait()
+            if exit != 0:
+                print(lines.decode('utf-8'))
+                print("Creating or uploading bdist_egg for", python, "failed")
+                sys.exit(1)
+
+            p = subprocess.Popen(
+                [python, 'setup.py', 'install'], 
+                cwd=srcdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+            lines, _ = p.communicate()
+            exit = p.wait()
+            if exit != 0:
+                print(lines.decode('utf-8'))
+                print("Installing for", python, "failed")
+                sys.exit(1)
+
+
+        # TODO: create and upload eggs for 'intel' builds of 2.7 and 3.2
+        # TODO: create and upload documentation (to packages.python.org)
+
+        print()
+
+
+def detect_frameworks():
+    """
+    Returns a list of framework wrappers in the order they should
+    be build in.
+    """
+    topdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+    frameworks = []
+    partial_order = []
+
+    for subdir in os.listdir(topdir):
+        if not subdir.startswith('pyobjc-framework-'): continue
+
+        setup = os.path.join(topdir, subdir, 'setup.py')
+
+        requires = None
+        with open(setup) as fp:
+            for ln in fp:
+                if requires is None:
+                    if ln.strip().startswith('install_requires'):
+                        requires = []
+                else:
+                    if ln.strip().startswith(']'):
+                        break
+
+                    dep = ln.strip()[1:-1]
+                    if dep.startswith('pyobjc-framework'):
+                        dep = dep.split('>')[0]
+                        requires.append(dep)
+
+        frameworks.append(subdir)
+        for dep in requires:
+            partial_order.append((dep, subdir))
+
+    frameworks = topological_sort(frameworks, partial_order)
+    return frameworks
+
+if __name__ == "__main__":
+    main()

build-support/run_tests.py

 
 
 gUsage = """\
-run_tests.py [-a archs] [--archs=archs] [-v versions] [--versions,versions]
+run_tests.py [-a archs] [--archs=archs] [-v versions] [--versions=versions] [-s|--setup-only]
 
 archs:    32-bit,3-way (values separated by commas)
 versions: 2.6,2.7,3.1,3.2    (values seperated by commas)
     logging.basicConfig(level=logging.DEBUG)
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'a:v:h?', ["help", "archs=", "versions="])
+        opts, args = getopt.getopt(sys.argv[1:], 'a:v:h?s', ["help", "archs=", "versions=", "setup-only"])
     except getopt.error as msg:
         print(msg, file=sys.stderr)
         print(gUsage, file=sys.stderr)
 
     versions=gVersions
     archs=gArchs
+    setup_only=False
 
     for k, v in opts:
         if k in ('-?', '-h', '--help'):
                     print("Unsupported Python version: {0}".format(v),
                             file=sys.stderr)
                     sys.exit(1)
+
+        elif k in ['-s', '--setup-only']:
+            setup_only = True
+
         else:
             print("ERROR: Unhandled script option: {0}".format(k),
                     file=sys.stderr)
 
     for ver in versions:
         for arch in archs:
-            run_tests(ver, arch)
+            run_tests(ver, arch, setup_only)
+
+    if setup_only:
+        return
 
     gen_summary(versions, archs)
 
 
 
 
-def run_tests(version, archs):
+def run_tests(version, archs, setup_only):
 
     lg = logging.getLogger("run_tests")
 
             lg.warning("Install %s failed", pkg)
             raise RuntimeError(pkg)
 
+    if setup_only:
+        lg.info("Don't actually run the tests")
+        return
+
     lg.debug("Start testing cycle")
     for pkg in ["pyobjc-core"] + detect_frameworks():
         if not os.path.exists(os.path.join(resultdir, pkg)):

pyobjc-core/Tools/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-AddressBook/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-AppleScriptKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-AppleScriptObjC/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-Automator/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-CFNetwork/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-CalendarStore/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-Cocoa/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-Collaboration/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-CoreData/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-CoreLocation/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-CoreText/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-DictionaryServices/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-ExceptionHandling/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-FSEvents/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-InputMethodKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-InstallerPlugins/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-InstantMessage/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-InterfaceBuilderKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-LatentSemanticMapping/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-LaunchServices/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-Message/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-OpenDirectory/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-PreferencePanes/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-PubSub/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-QTKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-Quartz/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-ScreenSaver/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-ScriptingBridge/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-SearchKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-ServerNotification/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-ServiceManagement/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-SyncServices/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-SystemConfiguration/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-WebKit/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:

pyobjc-framework-XgridFoundation/pyobjc_setup.py

 
         else:
             data = gPyObjCAPI_H
-            open(os.path.join(include_rot, 'pyobjc-api.h'), 'w').write(data)
+            open(os.path.join(include_root, 'pyobjc-api.h'), 'w').write(data)
 
         for e in self.extensions:
             if include_root not in e.include_dirs:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.