Commits

Ronald Oussoren committed 5772c72

working on 2to3-less bootstrap

Comments (0)

Files changed (298)

pyobjc-core/Lib/PyObjCTools/TestSupport.py

 
 def _typemap(tp):
     if tp is None: return None
-    return tp.replace('_NSRect', 'CGRect').replace('_NSPoint', 'CGPoint').replace('_NSSize', 'CGSize')
+    return tp.replace(b'_NSRect', b'CGRect').replace(b'_NSPoint', b'CGPoint').replace(b'_NSSize', b'CGSize')
 
 def sdkForPython(_cache=[]):
     """
     This also adds a number of useful assertion methods
     """
 
+    if not hasattr(_unittest.TestCase, 'assertItemsEqual'):
+        def assertItemsEqual(self, seq1, seq2, message=None):
+            self.assertEqual(set(seq1), set(seq2), message)
+
     def assertGreaterThan(self, value, test, message = None):
         if not (value > test):
             self.fail(message or "not: %s > %s"%(value, test))

pyobjc-core/Lib/PyObjCTools/_BSCompiler.py

-"""
-Helper script for compiling .brigesupport files into a more compact form
-
-Note: the format of the compiled data is unstable for now, new versions
-of PyObjC can and will use different formats.
-"""
-import getopt
-import sys
-from xml.etree import ElementTree
-import os
-import time
-import json
-
-import objc
-
-gUsage = "Usage: pyobjc-compile-bridgesupport --input=FILE --output=FILE"
-
-class bstr(str):
-    __slots__ = ()
-
-    def __repr__(self):
-        result = super(bstr, self).__repr__()
-        if result.startswith('b'):
-            return result
-        return 'b' + result
-
-class funccall (object):
-    def __init__(self, name, args=None, kwds=None):
-        self._name = name
-
-        self._args = ()
-        self._kwds = {}
-
-        if args is not None:
-            self._args = args
-        if kwds is not None:
-            self._kwds = kwds
-
-    def __call__(self, *args, **kwds):
-        self._args = args
-        self._kwds = kwds
-
-    def __repr__(self):
-        result = [self._name, '(']
-        for a in self._args:
-            if result[-1] != '(':
-                result.append(', ')
-            result.append(repr(a))
-
-        for k in self._kwds:
-            v = self.kwds[k]
-            if result[-1] != '(':
-                result.append(', ')
-            result.append(k)
-            result.append('=')
-            result.append(repr(v))
-        result.append(')')
-        return ''.join(result)
-
-def sel32or64(a, b):
-    return funccall('sel32or64', (a, b))
-
-def littleOrBig(a, b):
-    return funccall('littleOrBig', (a, b))
-
-
-def main():
-    try:
-        opts, args = getopt.getopt(sys.argv[1:], 'Vh?i:o:', ['version', 'help', 'input=', 'output='])
-
-    except getopt.error,  msg:
-        print >>sys.stderr, msg
-        print >>sys.stderr, gUsage
-        sys.exit(1)
-
-    input = None
-    output = None
-
-    if args:
-        print >>sys.stderr, "Additional arguments"
-        print >>sys.stderr, gUsage
-        sys.exit(1)
-
-    for k, v in opts:
-        if k in ('-V', '--version'):
-            print "pyobjc %s"%(objc.__version__,)
-            sys.exit(0)
-
-        elif k in ('-h', '-?', '--help'):
-            print gUsage
-            sys.exit(0)
-
-        elif k in ('-i', '--input'):
-            input = v
-
-        elif k in ('-o', '--output'):
-            output = v 
-
-        else:
-            raise RuntimeError("Unhandled command-line option")
-
-
-    if input is None or output is None:
-        print >>sys.stderr, "Specify input and output files"
-        print >>sys.stderr, gUsage
-        sys.exit(1)
-
-    try:
-        input_tree = ElementTree.parse(input)
-    except Exception, msg:
-        print >>sys.stderr, msg
-        sys.exit(1)
-
-    fp = open(output, 'w')
-    print >>fp, "# Generated file, don't edit"
-    print >>fp, "# Source: %s"%(input,)
-    print >>fp, "# Last update: %s"%(time.ctime(),)
-    print >>fp, ""
-    print >>fp, "import objc, sys"
-    print >>fp, ""
-    print >>fp, "if sys.maxint > 2 ** 32:"
-    print >>fp, "    def sel32or64(a, b): return b"
-    print >>fp, "else:"
-    print >>fp, "    def sel32or64(a, b): return a"
-    print >>fp, "if sys.byteorder == 'little':"
-    print >>fp, "    def littleOrBig(a, b): return a"
-    print >>fp, "else:"
-    print >>fp, "    def littleOrBig(a, b): return b"
-    print >>fp, ""
-
-    emit_misc(fp, input_tree)
-    emit_constants(fp, input_tree)
-    emit_enums(fp, input_tree)
-    emit_strconsts(fp, input_tree)
-    emit_functions(fp, input_tree)
-    emit_cftype(fp, input_tree)
-    emit_classes(fp, input_tree)
-    emit_informal_protocols(fp, input_tree)
-    emit_null(fp, input_tree)
-
-def rewrite_typecode(value):
-    result = []
-
-    while value and value[0] in (objc._C_PTR, objc._C_IN, objc._C_INOUT, objc._C_ONEWAY, objc._C_CONST):
-        result.append(value[0])
-        value = value[1:]
-
-    if not value:
-        return ''.join(result), ''
-
-    if value[0] == objc._C_BOOL:
-        result.append(objc._C_NSBOOL)
-        value = value[1:]
-
-    elif value[0] == objc._C_NSBOOL:
-        result.append(objc._C_BOOL)
-        value = value[1:]
-
-    elif value[0] == objc._C_STRUCT_B:
-        while value[0] != '=' and value[0] != objc._C_STRUCT_E:
-            result.append(value[0])
-            value = value[1:]
-
-        if value[0] == '=':
-            result.append(value[0])
-            value = value[1:]
-
-        while value[0] != objc._C_STRUCT_E:
-            if value[0] == '"':
-                # Embedded field name
-                result.append(value[0])
-                value = value[1:]
-                while value[0] != '"':
-                    result.append(value[0])
-                    value = value[1:]
-                result.append(value[0])
-                value = value[1:]
-
-            cur, value = rewrite_typecode(value)
-            result.append(cur)
-
-        result.append(objc._C_STRUCT_E)
-        value = value[1:]
-
-    elif value[0] == objc._C_UNION_B:
-        while value[0] != '=' and value[0] != objc._C_UNION_E:
-            result.append(value[0])
-            value = value[1:]
-
-        if value[0] == '=':
-            result.append(value[0])
-            value = value[1:]
-
-        while value[0] != objc._C_UNION_E:
-            if value[0] == '"':
-                # Embedded field name
-                result.append(value[0])
-                value = value[1:]
-                while value[0] != '"':
-                    result.append(value[0])
-                    value = value[1:]
-                result.append(value[0])
-                value = value[1:]
-
-            cur, value = rewrite_typecode(value)
-            result.append(cur)
-
-        result.append(objc._C_UNION_E)
-        value = value[1:]
-
-    elif value[0] == objc._C_ARY_B:
-        result.append(value[0])
-        value = value[1:]
-        while value[0].isdigit():
-            result.append(value[0])
-            value = value[1:]
-
-        while value[0] != objc._C_ARY_E:
-            cur, value = rewrite_typecode(value)
-            result.append(cur)
-
-        result.append(value[0])
-        value = value[1:]
-
-    else:
-        result.append(value[0])
-        value = value[1:]
-
-    return ''.join(result), value
-
-def rewrite_typestr(value):
-    if value is None: return value
-    result = []
-
-    cur, rest = rewrite_typecode(value)
-    result.append(cur)
-
-    while rest:
-        cur, rest = rewrite_typecode(rest)
-        result.append(cur)
-    return ''.join(result)
-
-def emit_misc(fp, tree):
-    fp.write("misc = {\n")
-
-    for node in tree.findall('.//opaque'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        name = node.get('name')
-        type = node.get('type')
-        type64 = node.get('type64')
-
-        if type64 is None or type == type64:
-            fp.write('    "%s": objc.createOpaquePointerType(%r, b%r),\n'%(
-                name, name, rewrite_typestr(type)))
-        else:
-            fp.write('    "%s": objc.createOpaquePointerType(%r, sel32or64(b%r, b%r)),\n'%(
-                name, name, rewrite_typestr(type), rewrite_typestr(type64)))
-
-    for node in tree.findall('.//struct'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        name = node.get('name')
-        type = node.get('type')
-        type64 = node.get('type64')
-
-
-        if type64 is None or type == type64:
-            fp.write('    "%s": objc.createStructType(%r, b%r, None),\n'%(
-                name, name, rewrite_typestr(type)))
-        else:
-            fp.write('    "%s": objc.createStructType(%r, sel32or64(b%r, b%r), None),\n'%(
-                name, name, rewrite_typestr(type), rewrite_typestr(type64)))
-
-
-    fp.write("}\n")
-
-def emit_constants(fp, tree):
-    fixed = {}
-    fp.write("constants = '''$")
-    for node in tree.findall('.//constant'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        name = node.get("name")
-        type = rewrite_typestr(node.get("type", "@"))
-        type64 = node.get("type64", None)
-        if type64 is not None:
-            type64 = rewrite_typestr(type64)
-
-        if type[0] == '{':
-            _, rest = type.split('=', 1)
-            if '?' in rest:
-                # Skip structs with embedded function pointers and
-                # other unhandled types
-                continue
-
-        if type64 is not None and type64 != type:
-            fixed[name] = sel32or64(type, type64)
-            continue
-
-
-        if node.get("magic_cookie", "false") == "true":
-            type = "=" + type
-
-        if type == "@":
-            fp.write(name)
-        else:
-            fp.write(name)
-            fp.write("@")
-            fp.write(type)
-        fp.write("$")
-    fp.write("'''\n")
-    if fixed:
-        fp.write("constants_dict = %r\n"%(fixed,))
-
-
-def emit_enums(fp, tree):
-    others = {}
-    fp.write("enums = '''$")
-    for node in tree.findall('.//enum'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        name = node.get("name")
-        value = node.get("value")
-        value64 = node.get("value64")
-
-        if value is None and value64 is not None:
-            value = value64
-
-
-        if value is None:
-            le_value = int(node.get("le_value"))
-            be_value = int(node.get("be_value"))
-            others[name] = littleOrBig(le_value, be_value)
-
-        elif value64 is None or value64 == value:
-            fp.write(name)
-            fp.write("@")
-            fp.write(value)
-            fp.write("$")
-
-        else:
-            if '.' in value:
-                value = float(value)
-            else:
-                value = int(value)
-
-            if '.' in value64:
-                value64 = float(value64)
-            else:
-                value64 = int(value64)
-
-
-            others[name] = sel32or64(value, value64)
-
-    fp.write("'''\n")
-
-    if others:
-        fp.write("misc.update(%r)\n"%(others,))
-
-
-
-def emit_strconsts(fp, tree):
-    items = {}
-    for node in tree.findall('.//string_constant'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        nm = node.get('name')
-        value = node.get('value')
-        isstr = node.get('nsstring', 'false') == 'true'
-        if not isstr:
-            value = value.encode('ascii')
-        items[nm] = value
-
-    print >>fp, "misc.update(%s)"%(items)
-
-def emit_functions(fp, tree):
-    items = {}
-    for node in tree.findall('.//function'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-
-        name = node.get('name')
-        types = [b'v']
-        types64 = [b'v']
-        retval = None
-        arguments = []
-        meta = {}
-
-        if node.get('variadic', 'false') == 'true':
-            meta['variadic'] = 'true'
-            if node.get('c_array_delimited_by_null', 'false') == 'true':
-                meta['c_array_delimited_by_null'] = True
-
-            if node.get('c_array_length_in_arg') is not None:
-                meta['c_array_length_in_arg'] =  \
-                        int(node.get('c_array_length_in_arg'))
-
-        for child in node:
-            if child.tag == 'retval':
-                retval = {}
-                convert_argnode(False, child, retval)
-
-                if child.get('type64') is not None:
-                    types64[0] = rewrite_typestr(child.get('type64'))
-                else:
-                    types64[0] = rewrite_typestr(child.get('type'))
-
-                types[0] = rewrite_typestr(child.get('type'))
-
-            elif child.tag == 'arg':
-                info = {}
-                convert_argnode(False, child, info)
-                arguments.append(info)
-                
-                if child.get('type64') is not None:
-                    types64.append(rewrite_typestr(child.get('type64')))
-                else:
-                    types64.append(rewrite_typestr(child.get('type')))
-
-                types.append(rewrite_typestr(child.get('type')))
-
-            else:
-                raise ValueError("Child node %s of function node"%(child.tag,))
-
-        if retval is not None:
-            k = list(retval.keys())
-            k.sort()
-            if k in (['type'], ['type', 'type64']):
-                # No additional information, no need to store meta information
-                pass
-
-            else:
-                meta['retval'] = retval
-
-        if arguments:
-            have_meta = False
-            for a in arguments:
-                k = list(a.keys())
-                k.sort()
-                if k in (['type'], ['type', 'type64']):
-                    # No additional information, no need to store meta 
-                    # information
-                    pass
-                else:
-                    have_meta = True
-
-            if have_meta:
-                meta['arguments'] = dict(zip(range(len(arguments)), arguments))
-
-        if meta == {}:
-            meta = None
-
-        if types[0] is None:
-            types[0] = 'v'
-
-        if types64[0] is None:
-            types64[0] = 'v'
-
-
-        types = ''.join(types)
-        types64 = ''.join(types64)
-
-        if types != types64:
-            if meta is None:
-                items[name] = (sel32or64(types, types64),)
-            else:
-                items[name] = (sel32or64(types, types64), "", meta)
-        else:
-            if meta is None:
-                items[name] = (types,)
-            else:
-                items[name] = (types, "", meta)
-
-
-    fp.write("functions = %r\n"%(items,))
-
-
-BOOLEAN_ATTRIBUTES=[
-    ("already_retained", False),
-    ("already_cfretained", False),
-    ("c_array_length_in_result", False),
-    ("c_array_delimited_by_null", False),
-    ("c_array_of_variable_length", False),
-    ("printf_format", False),
-    ("free_result", False),
-    ("null_accepted", True),
-]
-
-def parse_callable(isfunction, node, dct):
-    if node.get('function_pointer_retained', 'true') == 'false':
-        dct['callable_retained'] = False
-
-    meta = dct['callable'] = {}
-    meta['arguments'] = arguments = {}
-    idx = 0
-
-    if not isfunction:
-        # Blocks have an implicit first argument
-        arguments[idx] = {
-                'type': '^v',
-        }
-        idx += 1
-
-    for child in node:
-        if child.tag == 'retval':
-            retval = meta['retval'] = {}
-            convert_argnode(False, child, retval)
-
-        elif child.tag == 'arg':
-            info = {}
-            convert_argnode(False, child, info)
-            arguments[idx] = info
-            idx += 1
-
-        else:
-            raise ValueError("Child node %s of function node"%(child.tag,))
-
-    if meta.get('retval') is None:
-        meta['retval'] = {
-            'type': 'v',
-        }
-
-        
-
-def convert_argnode(ismethod, node, dct):
-    if ismethod:
-        argoffset = 2
-    else:
-        argoffset = 0
-
-    v = node.get('type_modifier')
-    if v is not None:
-        dct['type_modifier'] = bstr(v)
-
-    type = node.get('type')
-    type64 = node.get('type64')
-    if type is not None:
-        if type64 is None or type == type64:
-            dct['type'] = bstr(rewrite_typestr(type))
-        else:
-            dct['type'] = sel32or64(
-                    bstr(rewrite_typestr(type)),
-                    bstr(rewrite_typestr(type64)))
-
-    sel_of_type = node.get('sel_of_type')
-    sel_of_type64 = node.get('sel_of_type64')
-    if sel_of_type is not None:
-        if sel_of_type64 is None or sel_of_type == sel_of_type64:
-            dct['sel_of_type'] = bstr(rewrite_typestr(sel_of_type))
-        else:
-            dct['sel_of_type'] = sel32or64(
-                    bstr(rewrite_typestr(sel_of_type)),
-                    bstr(rewrite_typestr(sel_of_type64)))
-
-    v = node.get('c_array_of_fixed_length')
-    if v is not None:
-        dct['c_array_of_fixed_length'] = int(v)
-
-
-    v = node.get('c_array_length_in_arg')
-    if v is not None:
-        if ',' in v:
-            a, b = v.split(',')
-            a = a.strip()
-            b = b.strip()
-
-            dct['c_array_length_in_arg'] = int(a)+argoffset, int(b)+argoffset
-        else:
-            dct['c_array_length_in_arg'] = int(v)+argoffset
-
-
-    v = node.get('function_pointer')
-    if v == 'true':
-        parse_callable(True, node, dct)
-
-    v = node.get('block')
-    if v == 'true':
-        parse_callable(False, node, dct)
-
-
-    for attr, default in BOOLEAN_ATTRIBUTES:
-        v = node.get(attr)
-        if v is not None:
-            if v == 'true':
-                v = True
-            else:
-                v = False
-
-            if v != default:
-                dct[attr] = v
-
-
-def emit_classes(fp, tree):
-    print >>fp, "r = objc.registerMetaDataForSelector"
-    print >>fp, "objc._updatingMetadata(True)"
-    print >>fp, "try:"
-    print >>fp, "    pass"
-    for node in tree.findall('.//class'):
-        if node.get('ignore', 'false') == 'true':
-            continue
-        clsname = node.get('name')
-        for method in node:
-            if method.tag != 'method': continue
-
-            if method.get('ignore', 'false') == 'true':
-                continue
-            sel = bstr(method.get('selector'))
-            meta = {}
-            if method.get('variadic', 'false') == 'true':
-                meta['variadic'] = 'true'
-                if method.get('c_array_delimited_by_null', 'false') == 'true':
-                    meta['c_array_delimited_by_null'] = True
-
-                if method.get('c_array_length_in_arg') is not None:
-                    meta['c_array_length_in_arg'] =  \
-                            int(node.get('c_array_length_in_arg'))
-            for info in method:
-                if info.tag == 'retval':
-                    n = meta['retval'] = {}
-                elif info.tag == 'arg':
-                    if 'arguments' not in meta:
-                        meta['arguments'] = {}
-
-                    n = meta['arguments'][int(info.get('index'))+2] = {}
-
-                convert_argnode(True, info, n)
-
-            print >>fp, '    r(%r, %r, %r)'%(clsname, sel, meta)
-
-    print >>fp, "finally:"
-    print >>fp, "    objc._updatingMetadata(False)"
-
-def emit_cftype(fp, tree):
-    print >>fp, "cftypes = []"
-    for node in tree.findall('.//cftype'):
-        name = node.get('name')
-        type = node.get('type')
-        type64= node.get('type64')
-        if type64 is not None and type64 != type:
-            type = sel32or64(type, type64)
-
-        gettypeid_func = node.get('gettypeid_func')
-        tollfree= node.get('tollfree')
-
-        print >>fp, "cftypes.append((%r, %r, %r, %r))"%(name, type, gettypeid_func, tollfree)
-
-
-
-
-def prot(name, methods):
-    return funccall('objc.informal_protocol', (name, methods))
-
-def sel(selector, type):
-    return funccall('objc.selector', (None, selector, type), {'isRequired': False})
-
-def emit_informal_protocols(fp, tree):
-    protocols = {
-    }
-    for node in tree.findall('.//informal_protocol'):
-        name = node.get('name')
-
-        methods = []
-
-        for method in node:
-            selector = method.get('selector')
-            type = rewrite_typestr(method.get('type'))
-            type64 = rewrite_typestr(method.get('type64'))
-
-            if type64 is not None and type != type64:
-                type = sel32or64(type, type64)
-
-            methods.append(sel(selector, type))
-
-        protocols[name] = prot(name, methods)
-
-    if protocols:
-        fp.write('protocols=%s\n'%(protocols))
-
-def emit_null(fp, tree):
-    values = {}
-    for node in tree.findall('.//null_const'):
-        name = node.get('name')
-        values[name] = None
-
-    if values:
-        fp.write('misc.update(%r)'%(values,))

pyobjc-core/Lib/objc/__init__.py

 
     module, name = name.rsplit('.', 1)
     m = __import__(module)
+    print (module, module.split('.')[1:])
     for k in module.split('.')[1:]:
+        print (k)
         m = getattr(m, k)
 
+    print (m, name)
     return getattr(m, name)
 

pyobjc-core/Lib/objc/_bridges.py

 from objc._objc import *
 from objc import _objc
 import struct
+import sys
 
 __all__ = [ 'registerListType', 'registerMappingType' ]
 
     except AttributeError:
         pass
 
+if sys.version_info[0] > 2:
+    registerListType(type(range(1)))
+
+else:
+    registerListType(xrange)
+
+
 _bridgePythonTypes()

pyobjc-core/Lib/objc/_convenience.py

 def _makeD(v):
     if isinstance(v, NSDecimalNumber):
         return v
+
+    print ("makeD(%r of %r)"%(v, type(v)))
     return NSDecimalNumber.decimalNumberWithDecimal_(v)
 
+def decimal__add__(self, other):
+    print ("decimal__add__(%r, %r)"%(self, other))
+    return _makeD(self.decimalValue() + other)
+
+def decimal__radd__(self, other):
+    print ("decimal__radd__(%r, %r)"%(self, other))
+    return _makeD(other + self.decimalValue())
+
 CLASS_METHODS['NSDecimalNumber'] = (
-    ('__add__', lambda self, other: _makeD(self.decimalValue() + other)),
-    ('__radd__', lambda self, other: _makeD(other + self.decimalValue())),
+    ('__add__', decimal__add__),
+    ('__radd__', decimal__radd__),
     ('__sub__', lambda self, other: _makeD(self.decimalValue() - other)),
     ('__rsub__', lambda self, other: _makeD(other - self.decimalValue())),
     ('__mul__', lambda self, other: _makeD(self.decimalValue() * other)),

pyobjc-core/Misc/pyobjc_setup.py

 
 __all__ = ('setup', 'Extension', 'Command')
 
-import ez_setup
-ez_setup.use_setuptools()
+import sys
+from pkg_resources import Distribution
+
+try:
+    import setuptools
+
+except ImportError:
+    import distribute_setup
+    distribute_setup.use_setuptools()
+
+from setuptools.command import test
+from setuptools.command import build_py
+
+from distutils import log
+
+class oc_build_py (build_py.build_py):
+    def build_packages(self):
+        log.info("overriding build_packages to copy PyObjCTest")
+        p = self.packages
+        self.packages = list(self.packages) + ['PyObjCTest']
+        try:
+            build_py.build_py.build_packages(self)
+        finally:
+            self.packages = p
+
+
+from pkg_resources import working_set, normalize_path, add_activation_listener, require
+
+class oc_test (test.test):
+    description = "run test suite"
+    user_options = [
+        ('verbosity=', None, "print what tests are run"),
+    ]
+
+    def initialize_options(self):
+        test.test.initialize_options(self)
+        self.verbosity='1'
+
+    def finalize_options(self):
+        test.test.finalize_options(self)
+        if isinstance(self.verbosity, str):
+            self.verbosity = int(self.verbosity)
+
+
+    def cleanup_environment(self):
+        ei_cmd = self.get_finalized_command('egg_info')
+        egg_name = ei_cmd.egg_name.replace('-', '_')
+
+        to_remove =  []
+        for dirname in sys.path:
+            bn = os.path.basename(dirname)
+            if bn.startswith(egg_name + "-"):
+                to_remove.append(dirname)
+
+        for dirname in to_remove:
+            log.info("removing installed %r from sys.path before testing"%(
+                dirname,))
+            sys.path.remove(dirname)
+
+        from pkg_resources import add_activation_listener
+        add_activation_listener(lambda dist: dist.activate())
+        working_set.__init__()
+
+    def add_project_to_sys_path(self):
+        from pkg_resources import normalize_path, add_activation_listener
+        from pkg_resources import working_set, require
+
+        self.reinitialize_command('egg_info')
+        self.run_command('egg_info')
+        self.reinitialize_command('build_ext', inplace=1)
+        self.run_command('build_ext')
+        
+        self.__old_path = sys.path[:]
+        self.__old_modules = sys.modules.copy()
+
+        if 'PyObjCTools' in sys.modules:
+            del sys.modules['PyObjCTools']
+
+
+        ei_cmd = self.get_finalized_command('egg_info')
+        sys.path.insert(0, normalize_path(ei_cmd.egg_base))
+        sys.path.insert(1, os.path.dirname(__file__))
+            
+        add_activation_listener(lambda dist: dist.activate())
+        working_set.__init__()
+        require('%s==%s'%(ei_cmd.egg_name, ei_cmd.egg_version))
+
+    def remove_from_sys_path(self):
+        from pkg_resources import working_set
+        sys.path[:] = self.__old_path
+        sys.modules.clear()
+        sys.modules.update(self.__old_modules)
+        working_set.__init__()
+
+
+    def run(self):
+        import unittest
+
+        # Ensure that build directory is on sys.path (py3k)
+        import sys
+
+        self.cleanup_environment()
+        self.add_project_to_sys_path()
+
+        import PyObjCTools.TestSupport as modo
+
+        from pkg_resources import EntryPoint
+        loader_ep = EntryPoint.parse("x="+self.test_loader)
+        loader_class = loader_ep.load(require=False)
+
+        try:
+            meta = self.distribution.metadata
+            name = meta.get_name()
+            test_pkg = name + "_tests"
+            suite = loader_class().loadTestsFromName(self.distribution.test_suite)
+
+            runner = unittest.TextTestRunner(verbosity=self.verbosity)
+            result = runner.run(suite)
+
+            # Print out summary. This is a structured format that
+            # should make it easy to use this information in scripts.
+            summary = dict(
+                count=result.testsRun,
+                fails=len(result.failures),
+                errors=len(result.errors),
+                xfails=len(getattr(result, 'expectedFailures', [])),
+                xpass=len(getattr(result, 'expectedSuccesses', [])),
+                skip=len(getattr(result, 'skipped', [])),
+            )
+            print("SUMMARY: %s"%(summary,))
+
+        finally:
+            self.remove_from_sys_path()
+
 
 from setuptools import setup as _setup, Extension as _Extension, Command
 from distutils.errors import DistutilsPlatformError
-from distutils.command import build, install, install_lib
-from setuptools.command import develop, test, build_ext
+from distutils.command import build, install
+from setuptools.command import develop, test, build_ext, install_lib
+import pkg_resources
+import shutil
+import os
 import plistlib
 import sys
 import __main__
 
+CLASSIFIERS = filter(None,
+"""
+Development Status :: 5 - Production/Stable
+Environment :: Console
+Environment :: MacOS X :: Cocoa
+Intended Audience :: Developers
+License :: OSI Approved :: MIT License
+Natural Language :: English
+Operating System :: MacOS :: MacOS X
+Programming Language :: Python
+Programming Language :: Python :: 2
+Programming Language :: Python :: 2.6
+Programming Language :: Python :: 2.7
+Programming Language :: Python :: 3
+Programming Language :: Python :: 3.1
+Programming Language :: Python :: 3.2
+Programming Language :: Objective C
+Topic :: Software Development :: Libraries :: Python Modules
+Topic :: Software Development :: User Interfaces
+""".splitlines())
+
+
 def get_os_level():
     pl = plistlib.readPlist('/System/Library/CoreServices/SystemVersion.plist')
     v = pl['ProductVersion']
             if 'PyObjCTest' in fn:
                 result[fn] = 1
 
+        result['PyObjCTest'] = 1
+        result[os.path.join(self.install_dir, 'PyObjCTest')] = 1
+        for fn in os.listdir('PyObjCTest'):
+            result[os.path.join('PyObjCTest', fn)] = 1
+            result[os.path.join(self.install_dir, 'PyObjCTest', fn)] = 1
+
         return result
 
+
+
 class pyobjc_build_ext (build_ext.build_ext):
     def run(self):
+
+        # Ensure that the PyObjC header files are available
+        # in 2.3 and later the headers are in the egg,
+        # before that we ship a copy.
+        dist, = pkg_resources.require('pyobjc-core')
+
+        include_root = os.path.join(self.build_temp, 'pyobjc-include')
+        if os.path.exists(include_root):
+            shutil.rmtree(include_root)
+
+        os.makedirs(include_root)
+        if dist.has_metadata('include'):
+            for fn in dist.metadata_listdir('include'):
+                data = dist.get_metadata('include/%s'%(fn,))
+                fp = open(os.path.join(include_root, fn), 'w')
+                try:
+                    fp.write(data)
+                finally:
+                    fp.close()
+
+        else:
+            data = gPyObjCAPI_H
+            fp = open(os.path.join(include_root, 'pyobjc-api.h'), 'w')
+            try:
+                fp.write(data)
+            finally:
+                fp.close()
+
+        for e in self.extensions:
+            if include_root not in e.include_dirs:
+                e.include_dirs.append(include_root)
+
+        # Run the actual build
         build_ext.build_ext.run(self)
+
+        # Then tweak the copy_extensions bit to ensure PyObjCTest gets
+        # copied to the right place.
         extensions = self.extensions
         self.extensions = [
             e for e in extensions if e.name.startswith('PyObjCTest') ]
         cmdclass=None,
         **kwds):
 
+
+    k = kwds.copy()
+
     os_level = get_os_level()
     os_compatible = True
     if sys.platform != 'darwin':
                     msg = "This distribution is only supported on MacOSX versions %s upto and including %s"%(
                             min_os_level, max_os_level)
                 else:
-                    msg = "This distribution is only support on MacOSX >= %s"%(min_os_level,)
+                    msg = "This distribution is only supported on MacOSX >= %s"%(min_os_level,)
             elif max_os_level != None:
-                    msg = "This distribution is only support on MacOSX <= %s"%(max_os_level,)
+                    msg = "This distribution is only supported on MacOSX <= %s"%(max_os_level,)
             else:
-                    msg = "This distribution is only support on MacOSX"
+                    msg = "This distribution is only supported on MacOSX"
 
             class subcommand (base_class):
                 def run(self):
 
             return subcommand
 
+        class no_test (oc_test):
+            def run(self):
+                print("WARNING: %s"%(msg,))
+                print()
+                print("SUMMARY: {'count': 0, 'fails': 0, 'errors': 0, 'xfails': 0, 'skip': 65, 'xpass': 0, 'message': msg }\n")
+
         cmdclass['build'] = create_command_subclass(build.build)
-        cmdclass['test'] = create_command_subclass(test.test)
-        cmdclass['install'] = create_command_subclass(install.install)
+        cmdclass['test'] = oc_test
+        cmdclass['install'] = create_command_subclass(pyobjc_install_lib)
         cmdclass['develop'] = create_command_subclass(develop.develop)
+        cmdclass['build_py'] = create_command_subclass(oc_build_py)
     else:
         cmdclass['build_ext'] = pyobjc_build_ext
         cmdclass['install_lib'] = pyobjc_install_lib
+        cmdclass['test'] = oc_test
+        cmdclass['build_py'] = oc_build_py
+
+    plat_name = "MacOS X"
+    plat_versions = []
+    if min_os_level is not None:
+        plat_versions.append(">=%s"%(min_os_level,))
+    if max_os_level is not None:
+        plat_versions.append("<=%s"%(min_os_level,))
+    if plat_versions:
+        plat_name += " (%s)"%(", ".join(plat_versions),)
 
     _setup(
         cmdclass=cmdclass, 
         author='Ronald Oussoren',
         author_email='pyobjc-dev@lists.sourceforge.net',
         url='http://pyobjc.sourceforge.net',
-        platforms = [ "MacOS X" ],
+        platforms = [ plat_name ],
         package_dir = { '': 'Lib', 'PyObjCTest': 'PyObjCTest' },
         dependency_links = [],
         package_data = { '': ['*.bridgesupport'] },
         test_suite='PyObjCTest',
-        zip_safe = True,
-        **kwds
+        zip_safe = False,
+        license = 'MIT License',
+        **k
     ) 
+
+
+gPyObjCAPI_H="""\
+#ifndef PyObjC_API_H
+#define PyObjC_API_H
+
+/*
+ * Use this in helper modules for the objc package, and in wrappers
+ * for functions that deal with objective-C objects/classes
+ * 
+ * This header defines some utility wrappers for importing and using 
+ * the core bridge. 
+ *
+ * This is the *only* header file that should be used to access 
+ * functionality in the core bridge.
+ *
+ * WARNING: this file is not part of the public interface of PyObjC and
+ * might change or be removed without warning or regard for backward
+ * compatibility.
+ */
+
+#include "Python.h"
+#include <objc/objc.h>
+
+#import <Foundation/Foundation.h>
+
+#ifndef CGFLOAT_DEFINED
+
+#ifdef __LP64__
+# error "Huh? 64-bit but no CFFloat available???"
+#endif
+
+typedef float CGFloat;
+#define CGFLOAT_MIN FLT_MIN
+#define CGFLOAT_MAX FLT_MAX
+#define CGFLOAT_IS_DOUBLE 0
+#define CGFLOAT_DEFINED
+
+#endif /* CGFLOAT_DEFINED */
+
+
+#ifndef NSINTEGER_DEFINED
+
+#ifdef __LP64__
+# error "Huh? 64-bit but no NSINTEGER available???"
+#endif
+
+typedef int NSInteger;
+typedef unsigned int NSUInteger;
+
+#define NSIntegerMax    LONG_MAX
+#define NSIntegerMin    LONG_MIN
+#define NSUIntegerMax   ULONG_MAX
+
+#define NSINTEGER_DEFINED
+
+#endif
+
+
+#ifndef PyObjC_COMPAT_H
+#if (PY_VERSION_HEX < 0x02050000)
+typedef int Py_ssize_t;
+#define PY_FORMAT_SIZE_T ""
+#define Py_ARG_SIZE_T "n"
+#define PY_SSIZE_T_MAX INT_MAX
+
+#else
+
+#define Py_ARG_SIZE_T "i"
+#endif
+#endif
+
+#import <Foundation/NSException.h>
+
+struct PyObjC_WeakLink {
+	const char* name;
+	void (*func)(void);
+};
+
+
+/* threading support */
+#ifdef NO_OBJC2_RUNTIME
+#define PyObjC_DURING \
+		Py_BEGIN_ALLOW_THREADS \
+		NS_DURING
+
+#define PyObjC_HANDLER NS_HANDLER
+
+#define PyObjC_ENDHANDLER \
+		NS_ENDHANDLER \
+		Py_END_ALLOW_THREADS
+#else
+
+#define	PyObjC_DURING \
+		Py_BEGIN_ALLOW_THREADS \
+		@try {
+
+#define PyObjC_HANDLER } @catch(volatile NSObject* _localException) { \
+		NSException* localException __attribute__((__unused__))= (NSException*)_localException;
+
+#define PyObjC_ENDHANDLER \
+		} \
+		Py_END_ALLOW_THREADS
+
+#endif
+
+#define PyObjC_BEGIN_WITH_GIL \
+	{ \
+		PyGILState_STATE _GILState; \
+		_GILState = PyGILState_Ensure(); 
+
+#define PyObjC_GIL_FORWARD_EXC() \
+		do { \
+            PyObjCErr_ToObjCWithGILState(&_GILState); \
+		} while (0)
+
+
+#define PyObjC_GIL_RETURN(val) \
+		do { \
+			PyGILState_Release(_GILState); \
+			return (val); \
+		} while (0)
+
+#define PyObjC_GIL_RETURNVOID \
+		do { \
+			PyGILState_Release(_GILState); \
+			return; \
+		} while (0)
+
+
+#define PyObjC_END_WITH_GIL \
+		PyGILState_Release(_GILState); \
+	}
+
+
+
+#include <objc/objc-runtime.h>
+
+/* On 10.1 there are no defines for the OS version. */
+#ifndef MAC_OS_X_VERSION_10_1
+#define MAC_OS_X_VERSION_10_1 1010
+#define MAC_OS_X_VERSION_MAX_ALLOWED MAC_OS_X_VERSION_10_1
+
+#error "MAC_OS_X_VERSION_10_1 not defined. You aren't running 10.1 are you?"
+
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_2
+#define MAC_OS_X_VERSION_10_2 1020
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_3
+#define MAC_OS_X_VERSION_10_3 1030
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_4
+#define MAC_OS_X_VERSION_10_4 1040
+#endif
+
+#ifndef MAC_OS_X_VERSION_10_5
+#define MAC_OS_X_VERSION_10_5 1050
+#endif
+
+/* Current API version, increase whenever:
+ * - Semantics of current functions change
+ * - Functions are removed
+ * Do not increase when adding a new function, the struct_len field
+ * can be used for detecting if a function has been added.
+ *
+ * HISTORY:
+ * - Version 2.2 adds PyObjCUnsupportedMethod_IMP 
+ *       and PyObjCUnsupportedMethod_Caller 
+ * - Version 2.1 adds PyObjCPointerWrapper_Register 
+ * - Version 2 adds an argument to PyObjC_InitSuper
+ * - Version 3 adds another argument to PyObjC_CallPython
+ * - Version 4 adds PyObjCErr_ToObjCGILState
+ * - Version 4.1 adds PyObjCRT_AlignOfType and PyObjCRT_SizeOfType
+ *         (PyObjC_SizeOfType is now deprecated)
+ * - Version 4.2 adds PyObjCRT_SELName
+ * - Version 4.3 adds PyObjCRT_SimplifySignature
+ * - Version 4.4 adds PyObjC_FreeCArray, PyObjC_PythonToCArray and
+ *   		PyObjC_CArrayToPython
+ * - Version 5 modifies the signature for PyObjC_RegisterMethodMapping,
+ *	PyObjC_RegisterSignatureMapping and PyObjCUnsupportedMethod_IMP,
+ *      adds PyObjC_RegisterStructType and removes PyObjC_CallPython
+ * - Version 6 adds PyObjCIMP_Type, PyObjCIMP_GetIMP and PyObjCIMP_GetSelector
+ * - Version 7 adds PyObjCErr_AsExc, PyGILState_Ensure
+ * - Version 8 adds PyObjCObject_IsUninitialized,
+        removes PyObjCSelector_IsInitializer
+ * - Version 9 (???)
+ * - Version 10 changes the signature of PyObjCRT_SimplifySignature
+ * - Version 11 adds PyObjCObject_Convert, PyObjCSelector_Convert,
+     PyObjCClass_Convert, PyObjC_ConvertBOOL, and PyObjC_ConvertChar
+ * - Version 12 adds PyObjCObject_New
+ * - Version 13 adds PyObjCCreateOpaquePointerType
+ * - Version 14 adds PyObjCObject_NewTransient, PyObjCObject_ReleaseTransient
+ * - Version 15 changes the interface of PyObjCObject_New
+ * - Version 16 adds PyObjC_PerformWeaklinking
+ * - Version 17 introduces Py_ssize_t support
+ * - Version 18 introduces several API incompatibilities
+ */
+#define PYOBJC_API_VERSION 18
+
+#define PYOBJC_API_NAME "__C_API__"
+
+/* 
+ * Only add items to the end of this list!
+ */
+typedef int (RegisterMethodMappingFunctionType)(
+			Class, 
+			SEL, 
+			PyObject *(*)(PyObject*, PyObject*, PyObject*),
+			void (*)(void*, void*, void**, void*));
+
+struct pyobjc_api {
+	int	      api_version;	/* API version */
+	size_t	      struct_len;	/* Length of this struct */
+	PyTypeObject* class_type;	/* PyObjCClass_Type    */
+	PyTypeObject* object_type;	/* PyObjCObject_Type   */
+	PyTypeObject* select_type;	/* PyObjCSelector_Type */
+
+	/* PyObjC_RegisterMethodMapping */
+	RegisterMethodMappingFunctionType *register_method_mapping;
+
+	/* PyObjC_RegisterSignatureMapping */
+	int (*register_signature_mapping)(
+			char*,
+			PyObject *(*)(PyObject*, PyObject*, PyObject*),
+			void (*)(void*, void*, void**, void*));
+
+	/* PyObjCObject_GetObject */
+	id (*obj_get_object)(PyObject*);
+
+	/* PyObjCObject_ClearObject */
+	void (*obj_clear_object)(PyObject*);
+
+	/* PyObjCClass_GetClass */
+	Class (*cls_get_class)(PyObject*);
+
+	/* PyObjCClass_New */
+	PyObject* (*cls_to_python)(Class cls);
+
+	/* PyObjC_PythonToId */
+	id (*python_to_id)(PyObject*);
+
+	/* PyObjC_IdToPython */
+	PyObject* (*id_to_python)(id);
+
+	/* PyObjCErr_FromObjC */
+	void (*err_objc_to_python)(NSException*);
+
+	/* PyObjCErr_ToObjC */
+	void (*err_python_to_objc)(void);
+
+	/* PyObjC_PythonToObjC */
+	int (*py_to_objc)(const char*, PyObject*, void*);
+
+	/* PyObjC_ObjCToPython */
+	PyObject* (*objc_to_py)(const char*, void*);
+
+	/* PyObjC_SizeOfType */
+	Py_ssize_t   (*sizeof_type)(const char*);
+
+	/* PyObjCSelector_GetClass */
+	Class	   (*sel_get_class)(PyObject* sel);
+
+	/* PyObjCSelector_GetSelector */
+	SEL	   (*sel_get_sel)(PyObject* sel);
+
+	/* PyObjC_InitSuper */ 	
+	void	(*fill_super)(struct objc_super*, Class, id);
+
+	/* PyObjC_InitSuperCls */
+	void	(*fill_super_cls)(struct objc_super*, Class, Class);
+
+	/* PyObjCPointerWrapper_Register */ 
+	int  (*register_pointer_wrapper)(
+		        const char*, PyObject* (*pythonify)(void*),
+			int (*depythonify)(PyObject*, void*)
+		);
+
+	void (*unsupported_method_imp)(void*, void*, void**, void*);
+	PyObject* (*unsupported_method_caller)(PyObject*, PyObject*, PyObject*);
+
+	/* PyObjCErr_ToObjCWithGILState */
+	void (*err_python_to_objc_gil)(PyGILState_STATE* state);
+
+	/* PyObjCRT_AlignOfType */
+	Py_ssize_t (*alignof_type)(const char* typestr);
+
+	/* PyObjCRT_SELName */
+	const char* (*selname)(SEL sel);
+
+	/* PyObjCRT_SimplifySignature */
+	int (*simplify_sig)(char* signature, char* buf, size_t buflen);
+
+	/* PyObjC_FreeCArray */
+	void    (*free_c_array)(int,void*);
+
+	/* PyObjC_PythonToCArray */
+	int     (*py_to_c_array)(BOOL, BOOL, const char*, PyObject*, void**, Py_ssize_t*, PyObject**);
+	
+	/* PyObjC_CArrayToPython */
+	PyObject* (*c_array_to_py)(const char*, void*, Py_ssize_t);
+
+	/* PyObjC_RegisterStructType */
+	PyObject* (*register_struct)(const char*, const char*, const char*, initproc, Py_ssize_t, const char**);
+
+	/* PyObjCIMP_Type */
+	PyTypeObject* imp_type;
+
+	/* PyObjCIMP_GetIMP */
+	IMP  (*imp_get_imp)(PyObject*);
+
+	/* PyObjCIMP_GetSelector */
+	SEL  (*imp_get_sel)(PyObject*);
+
+	/* PyObjCErr_AsExc */
+	NSException* (*err_python_to_nsexception)(void);
+
+	/* PyGILState_Ensure */
+	PyGILState_STATE (*gilstate_ensure)(void);
+
+	/* PyObjCObject_IsUninitialized */
+	int (*obj_is_uninitialized)(PyObject*);
+
+	/* PyObjCObject_Convert */
+	int (*pyobjcobject_convert)(PyObject*,void*);
+
+	/* PyObjCSelector_Convert */
+	int (*pyobjcselector_convert)(PyObject*,void*);
+
+	/* PyObjCClass_Convert */
+	int (*pyobjcclass_convert)(PyObject*,void*);
+
+	/* PyObjC_ConvertBOOL */
+	int (*pyobjc_convertbool)(PyObject*,void*);
+
+	/* PyObjC_ConvertChar */
+	int (*pyobjc_convertchar)(PyObject*,void*);
+
+	/* PyObjCObject_New */
+	PyObject* (*pyobjc_object_new)(id, int , int);
+
+	/* PyObjCCreateOpaquePointerType */
+	PyObject* (*pointer_type_new)(const char*, const char*, const char*);
+
+	/* PyObject* PyObjCObject_NewTransient(id objc_object, int* cookie); */
+	PyObject* (*newtransient)(id objc_object, int* cookie);
+
+	/* void PyObjCObject_ReleaseTransient(PyObject* proxy, int cookie); */
+	void (*releasetransient)(PyObject* proxy, int cookie);
+
+	void (*doweaklink)(PyObject*, struct PyObjC_WeakLink*);
+
+	const char* (*removefields)(char*, const char*);
+
+	PyObject** pyobjc_null;
+
+	int (*dep_c_array_count)(const char* type, Py_ssize_t count, BOOL strict, PyObject* value, void* datum);
+
+	PyObject* (*varlistnew)(const char* tp, void* array);
+};
+
+#ifndef PYOBJC_BUILD
+
+#ifndef PYOBJC_METHOD_STUB_IMPL
+static struct pyobjc_api*	PyObjC_API;
+#endif /* PYOBJC_METHOD_STUB_IMPL */
+
+#define PyObjCObject_Check(obj) PyObject_TypeCheck(obj, PyObjC_API->object_type)
+#define PyObjCClass_Check(obj)  PyObject_TypeCheck(obj, PyObjC_API->class_type)
+#define PyObjCSelector_Check(obj)  PyObject_TypeCheck(obj, PyObjC_API->select_type)
+#define PyObjCIMP_Check(obj)  PyObject_TypeCheck(obj, PyObjC_API->imp_type)
+#define PyObjCObject_GetObject (PyObjC_API->obj_get_object)
+#define PyObjCObject_ClearObject (PyObjC_API->obj_clear_object)
+#define PyObjCClass_GetClass   (PyObjC_API->cls_get_class)
+#define PyObjCClass_New 	     (PyObjC_API->cls_to_python)
+#define PyObjCSelector_GetClass (PyObjC_API->sel_get_class)
+#define PyObjCSelector_GetSelector (PyObjC_API->sel_get_sel)
+#define PyObjC_PythonToId      (PyObjC_API->python_to_id)
+#define PyObjC_IdToPython      (PyObjC_API->id_to_python)
+#define PyObjCErr_FromObjC     (PyObjC_API->err_objc_to_python)
+#define PyObjCErr_ToObjC       (PyObjC_API->err_python_to_objc)
+#define PyObjCErr_ToObjCWithGILState       (PyObjC_API->err_python_to_objc_gil)
+#define PyObjCErr_AsExc        (PyObjC_API->err_python_to_nsexception)
+#define PyObjC_PythonToObjC    (PyObjC_API->py_to_objc)
+#define PyObjC_ObjCToPython    (PyObjC_API->objc_to_py)
+#define PyObjC_RegisterMethodMapping (PyObjC_API->register_method_mapping)
+#define PyObjC_RegisterSignatureMapping (PyObjC_API->register_signature_mapping)
+#define PyObjC_SizeOfType      (PyObjC_API->sizeof_type)
+#define PyObjC_PythonToObjC   (PyObjC_API->py_to_objc)
+#define PyObjC_ObjCToPython   (PyObjC_API->objc_to_py)
+#define PyObjC_InitSuper	(PyObjC_API->fill_super)
+#define PyObjC_InitSuperCls	(PyObjC_API->fill_super_cls)
+#define PyObjCPointerWrapper_Register (PyObjC_API->register_pointer_wrapper)
+#define PyObjCUnsupportedMethod_IMP (PyObjC_API->unsupported_method_imp)
+#define PyObjCUnsupportedMethod_Caller (PyObjC_API->unsupported_method_caller)
+#define PyObjCRT_SizeOfType      (PyObjC_API->sizeof_type)
+#define PyObjCRT_AlignOfType	(PyObjC_API->alignof_type)
+#define PyObjCRT_SELName	(PyObjC_API->selname)
+#define PyObjCRT_SimplifySignature	(PyObjC_API->simplify_sig)
+#define PyObjC_FreeCArray	(PyObjC_API->free_c_array)
+#define PyObjC_PythonToCArray	(PyObjC_API->py_to_c_array)
+#define PyObjC_CArrayToPython	(PyObjC_API->c_array_to_py)
+#define PyObjC_RegisterStructType   (PyObjC_API->register_struct)
+#define PyObjCIMP_GetIMP   (PyObjC_API->imp_get_imp)
+#define PyObjCIMP_GetSelector   (PyObjC_API->imp_get_sel)
+#define PyObjCObject_IsUninitialized (PyObjC_API->obj_is_uninitialized)
+#define PyObjCObject_Convert (PyObjC_API->pyobjcobject_convert)
+#define PyObjCSelector_Convert (PyObjC_API->pyobjcselector_convert)
+#define PyObjCClass_Convert (PyObjC_API->pyobjcselector_convert)
+#define PyObjC_ConvertBOOL (PyObjC_API->pyobjc_convertbool)
+#define PyObjC_ConvertChar (PyObjC_API->pyobjc_convertchar)
+#define PyObjCObject_New (PyObjC_API->pyobjc_object_new)
+#define PyObjCCreateOpaquePointerType (PyObjC_API->pointer_type_new)
+#define PyObjCObject_NewTransient (PyObjC_API->newtransient)
+#define PyObjCObject_ReleaseTransient (PyObjC_API->releasetransient)
+#define PyObjC_PerformWeaklinking (PyObjC_API->doweaklink)
+#define PyObjCRT_RemoveFieldNames (PyObjC_API->removefields)
+#define PyObjC_NULL		  (*(PyObjC_API->pyobjc_null))
+#define PyObjC_DepythonifyCArray  (PyObjC_API->dep_c_array_count)
+#define PyObjC_VarList_New  (PyObjC_API->varlistnew)
+
+
+#ifndef PYOBJC_METHOD_STUB_IMPL
+
+static int
+PyObjC_ImportAPI(PyObject* calling_module)
+{
+	PyObject* m;
+	PyObject* d;
+	PyObject* api_obj;
+	PyObject* name = PyString_FromString("objc");
+	
+	m = PyImport_Import(name);
+	Py_DECREF(name);
+	if (m == NULL) {
+		return -1;
+	}
+
+	d = PyModule_GetDict(m);
+	if (d == NULL) {
+		PyErr_SetString(PyExc_RuntimeError, 
+			"No dict in objc module");
+		return -1;
+	}
+
+	api_obj = PyDict_GetItemString(d, PYOBJC_API_NAME);
+	if (api_obj == NULL) {
+		PyErr_SetString(PyExc_RuntimeError, 
+			"No C_API in objc module");
+		return -1;
+	}
+	PyObjC_API = PyCObject_AsVoidPtr(api_obj);
+	if (PyObjC_API == NULL) {
+		return 0;
+	}
+	if (PyObjC_API->api_version != PYOBJC_API_VERSION) {
+		PyErr_SetString(PyExc_RuntimeError,
+			"Wrong version of PyObjC C API");
+		return -1;
+	}
+	
+	if (PyObjC_API->struct_len < sizeof(struct pyobjc_api)) {
+		PyErr_SetString(PyExc_RuntimeError,
+			"Wrong struct-size of PyObjC C API");
+		return -1;
+	}
+
+	Py_INCREF(api_obj);
+
+	/* Current pyobjc implementation doesn't allow deregistering 
+	 * information, avoid unloading of users of the C-API.
+	 * (Yes this is ugle, patches to fix this situation are apriciated)
+	 */
+	Py_INCREF(calling_module);
+
+	return 0;
+}
+#endif /* PYOBJC_METHOD_STUB_IMPL */
+
+#else /* PyObjC_BUILD */
+
+extern struct pyobjc_api	objc_api;
+
+#endif /* !PYOBJC_BUILD */
+
+#endif /*  PyObjC_API_H */
+"""

pyobjc-core/PyObjCTest/dejagnu.py

             CFLAGS=re.sub('\s+-isysroot\s+\S+\s+', ' ', CFLAGS)
 
         CC=get_config_var('CC')
+        CC += " -v"
 
         commandline='MACOSX_DEPLOYMENT_TARGET=%s %s %s -g -DMACOSX -Ilibffi-src/include -Ilibffi-src/powerpc -o /tmp/test.bin %s %s %s 2>&1'%(
                 get_config_var('MACOSX_DEPLOYMENT_TARGET'),
     license = 'MIT License',
     download_url = 'http://pyobjc.sourceforge.net/software/index.php',
     zip_safe = False,
-    entry_points = {
-        "console_scripts": [
-            "pyobjc-compile-brigesupport = PyObjCTools._BSCompiler:main",
-        ],
-    },
 )

pyobjc-framework-Accounts/pyobjc_setup.py

 
             return subcommand
 
+        class no_test (oc_test):
+            def run(self):
+                print("WARNING: %s"%(msg,))
+                print()
+                print("SUMMARY: {'count': 0, 'fails': 0, 'errors': 0, 'xfails': 0, 'skip': 65, 'xpass': 0, 'message': msg }\n")
+
         cmdclass['build'] = create_command_subclass(build.build)
-        cmdclass['test'] = create_command_subclass(oc_test)
+        cmdclass['test'] = oc_test
         cmdclass['install'] = create_command_subclass(pyobjc_install_lib)
         cmdclass['develop'] = create_command_subclass(develop.develop)
         cmdclass['build_py'] = create_command_subclass(oc_build_py)

pyobjc-framework-AddressBook/Lib/AddressBook/_metadata.py

 
 import objc, sys
 
-if sys.maxint > 2 ** 32:
+if sys.maxsize > 2 ** 32:
     def sel32or64(a, b): return b
 else:
     def sel32or64(a, b): return a