1'''
2Wrappers for the core Cocoa frameworks: CoreFoundation, Foundation and
3AppKit.
4
5These wrappers don't include documentation, please check Apple's documention
6for information on how to use these frameworks and PyObjC's documentation
7for general tips and tricks regarding the translation between Python
8and (Objective-)C frameworks
9'''
10import ez_setup
11ez_setup.use_setuptools()
12
13from setuptools import setup, Extension
14
15from setuptools.command import build_ext, install_lib
16
17import os
18if int(os.uname()[2].split('.')[0]) <= 8:
19    CFLAGS=["-DNO_OBJC2_RUNTIME"]
20    LDFLAGS=[]
21else:
22    CFLAGS=[]
23    LDFLAGS=CFLAGS
24
25try:
26    from PyObjCMetaData.commands import extra_cmdclass, extra_options
27except ImportError:
28    extra_cmdclass = {}
29    extra_options = lambda name: {}
30
31
32from setuptools.command import build_ext, install_lib
33import os
34
35class pyobjc_install_lib (install_lib.install_lib):
36    def get_exclusions(self):
37        result = install_lib.install_lib.get_exclusions(self)
38        for fn in install_lib._install_lib.get_outputs(self):
39            if 'PyObjCTest' in fn:
40                result[fn] = 1
41
42        return result
43
44class pyobjc_build_ext (build_ext.build_ext):
45    def run(self):
46        build_ext.build_ext.run(self)
47        extensions = self.extensions
48        self.extensions = [
49            e for e in extensions if e.name.startswith('PyObjCTest') ]
50        self.copy_extensions_to_source()
51        self.extensions = extensions
52
53extra_cmdclass['build_ext'] = pyobjc_build_ext
54extra_cmdclass['install_lib'] = pyobjc_install_lib
55
56setup(
57    name='pyobjc-framework-Cocoa',
58    version='2.2b3',
59    description = "Wrappers for the Cocoa frameworks on Mac OS X",
60    long_description = __doc__,
61    author='Ronald Oussoren',
62    author_email='pyobjc-dev@lists.sourceforge.net',
63    url='http://pyobjc.sourceforge.net',
64    platforms = [ "MacOS X" ],
65    packages = [ "Cocoa", "CoreFoundation", "Foundation", "AppKit", "PyObjCTools" ],
66    namespace_packages = ['PyObjCTools'],
67
68    package_dir = { '': 'Lib', 'PyObjCTest': 'PyObjCTest' },
69    install_requires = [
70        'pyobjc-core>=2.2b1',
71    ],
72    dependency_links = [],
73    package_data = {
74        '': ['*.bridgesupport']
75    },
76    zip_safe = False,
77    test_suite='PyObjCTest',
78
79    cmdclass = extra_cmdclass,
80    options = extra_options('Cocoa'),
81
82    ext_modules = [
83        # CoreFoundation
84        Extension('CoreFoundation._inlines',
85                [ 'Modules/_CoreFoundation_inlines.m' ],
86                extra_compile_args=CFLAGS,
87                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
88        Extension('CoreFoundation._CFCalendar',
89                [ 'Modules/_CoreFoundation_CFCalendar.m' ],
90                extra_compile_args=CFLAGS,
91                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
92        Extension('CoreFoundation._CFTree',
93                [ 'Modules/_CoreFoundation_CFTree.m' ],
94                extra_compile_args=CFLAGS,
95                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
96        Extension('CoreFoundation._CFBag',
97                [ 'Modules/_CoreFoundation_CFBag.m' ],
98                extra_compile_args=CFLAGS,
99                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
100        Extension('CoreFoundation._CFBinaryHeap',
101                [ 'Modules/_CoreFoundation_CFBinaryHeap.m' ],
102                extra_compile_args=CFLAGS,
103                extra_link_args=CFLAGS +['-framework', 'CoreFoundation']),
104        Extension('CoreFoundation._CFBitVector',
105                [ 'Modules/_CoreFoundation_CFBitVector.m' ],
106                extra_compile_args=CFLAGS,
107                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
108        Extension('CoreFoundation._CFDictionary',
109                [ 'Modules/_CoreFoundation_CFDictionary.m' ],
110                extra_compile_args=CFLAGS,
111                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
112        Extension('CoreFoundation._CFFileDescriptor',
113                [ 'Modules/_CoreFoundation_CFFileDescriptor.m' ],
114                extra_compile_args=CFLAGS,
115                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
116        Extension('CoreFoundation._CFMachPort',
117                [ 'Modules/_CoreFoundation_CFMachPort.m' ],
118                extra_compile_args=CFLAGS,
119                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
120        Extension('CoreFoundation._CFMessagePort',
121                [ 'Modules/_CoreFoundation_CFMessagePort.m' ],
122                extra_compile_args=CFLAGS,
123                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
124        Extension('CoreFoundation._CFNumber',
125                [ 'Modules/_CoreFoundation_CFNumber.m' ],
126                extra_compile_args=CFLAGS,
127                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
128        Extension('CoreFoundation._CFReadStream',
129                [ 'Modules/_CoreFoundation_CFReadStream.m' ],
130                extra_compile_args=CFLAGS,
131                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
132        Extension('CoreFoundation._CFSet',
133                [ 'Modules/_CoreFoundation_CFSet.m' ],
134                extra_compile_args=CFLAGS,
135                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
136        Extension('CoreFoundation._CFSocket',
137                [ 'Modules/_CoreFoundation_CFSocket.m' ],
138                extra_compile_args=CFLAGS,
139                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
140        Extension('CoreFoundation._CFWriteStream',
141                [ 'Modules/_CoreFoundation_CFWriteStream.m' ],
142                extra_compile_args=CFLAGS,
143                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
144        Extension('CoreFoundation._CFRunLoopObserver',
145                [ 'Modules/_CoreFoundation_CFRunLoopObserver.m' ],
146                extra_compile_args=CFLAGS,
147                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
148        Extension('CoreFoundation._CFRunLoopSource',
149                [ 'Modules/_CoreFoundation_CFRunLoopSource.m' ],
150                extra_compile_args=CFLAGS,
151                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
152        Extension('CoreFoundation._CFRunLoopTimer',
153                [ 'Modules/_CoreFoundation_CFRunLoopTimer.m' ],
154                extra_compile_args=CFLAGS,
155                extra_link_args=CFLAGS + ['-framework', 'CoreFoundation']),
156
157        # Foundation
158        Extension('Foundation._nsinvocation',
159                [ 'Modules/_Foundation_nsinvocation.m' ],
160                extra_compile_args=CFLAGS,
161                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
162        Extension('Foundation._NSDecimal',
163                [ 'Modules/_Foundation_NSDecimal.m' ],
164                extra_compile_args=CFLAGS,
165                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
166        Extension('Foundation._functioncallbacks',
167                [ 'Modules/_Foundation_functioncallbacks.m' ],
168                extra_compile_args=CFLAGS,
169                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
170        Extension('Foundation._nscoder',
171                [ 'Modules/_Foundation_nscoder.m' ],
172                extra_compile_args=CFLAGS,
173                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
174        Extension('Foundation._typecode',
175                [ 'Modules/_Foundation_typecode.m' ],
176                extra_compile_args=CFLAGS,
177                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
178        Extension('Foundation._inlines',
179                [ 'Modules/_Foundation_inlines.m' ],
180                extra_compile_args=CFLAGS,
181                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
182        Extension('Foundation._data',
183                [ 'Modules/_Foundation_data.m' ],
184                extra_compile_args=CFLAGS,
185                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
186        Extension('Foundation._netservice',
187                [ 'Modules/_Foundation_netservice.m' ],
188                extra_compile_args=CFLAGS,
189                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
190        Extension('Foundation._string',
191                [ 'Modules/_Foundation_string.m' ],
192                extra_compile_args=CFLAGS,
193                extra_link_args=CFLAGS + ['-framework', 'Foundation']),
194
195        # AppKit
196        Extension("AppKit._inlines",
197            [ "Modules/_AppKit_inlines.m" ],
198            extra_compile_args=CFLAGS,
199            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
200        Extension("AppKit._appmain",
201            [ "Modules/_AppKit_appmain.m" ],
202            extra_compile_args=CFLAGS,
203            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
204        Extension("AppKit._nsfont",
205            [ "Modules/_AppKit_nsfont.m"],
206            extra_compile_args=CFLAGS,
207            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
208        Extension("AppKit._nsquickdrawview",
209            [ "Modules/_AppKit_nsquickdrawview.m"],
210            extra_compile_args=CFLAGS,
211            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
212        Extension("AppKit._nsbezierpath",
213            [ "Modules/_AppKit_nsbezierpath.m"],
214            extra_compile_args=CFLAGS,
215            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
216        Extension("AppKit._nsview",
217            [ "Modules/_AppKit_nsview.m"],
218            extra_compile_args=CFLAGS,
219            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
220        Extension("AppKit._nsbitmap",
221            [ "Modules/_AppKit_nsbitmap.m"],
222            extra_compile_args=CFLAGS,
223            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
224        Extension("AppKit._nswindow",
225            [ "Modules/_AppKit_nswindow.m"],
226            extra_compile_args=CFLAGS,
227            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
228        Extension("AppKit._carbon",
229            [ "Modules/_AppKit_carbon.m"],
230            extra_compile_args=CFLAGS,
231            extra_link_args=CFLAGS + ["-framework", "AppKit"]),
232
233
234        #
235        # Test support
236        #
237        Extension("PyObjCTest.testhelper",
238            [ "Modules/testhelper.m"],
239            extra_compile_args=CFLAGS,
240            extra_link_args=CFLAGS + ["-framework", "Foundation"]),
241    ],
242)
243