File: setup.py

package info (click to toggle)
python-enable 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 7,280 kB
  • ctags: 13,899
  • sloc: cpp: 48,447; python: 28,502; ansic: 9,004; makefile: 315; sh: 44
file content (101 lines) | stat: -rw-r--r-- 4,046 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env python

import os
import platform
import sys

def configuration(parent_package='', top_path=None):
    from numpy.distutils.misc_util import Configuration
    from numpy.distutils.system_info import dict_append, get_info
    config = Configuration('quartz', parent_package, top_path)

    def generate_c_from_cython(extension, build_dir):
        if not sys.platform == 'darwin':
            print 'No %s will be built for this platform.' % (extension.name)
            return
        from distutils.dep_util import newer_group
        name = extension.name.split('.')[-1]
        source = extension.depends[0]
        target = os.path.join(build_dir, name+'.c')

        if newer_group(extension.depends, target):
            from Cython.Compiler import Main
            options = Main.CompilationOptions(
                defaults=Main.default_options,
                output_file=target)
            cython_result = Main.compile(source, options=options)
            if cython_result.num_errors != 0:
                raise RuntimeError("%d errors in Cython compile" %
                    cython_result.num_errors)
        return target

    frameworks = ['CoreFoundation','ApplicationServices','Foundation']
    extra_link_args=['-framework %s' % x for x in frameworks]
    include_dirs = [
        '/System/Library/Frameworks/%s.framework/Versions/A/Headers' % x
        for x in frameworks
    ]

    config.add_extension('ABCGI',
                         [generate_c_from_cython],
                         extra_link_args = extra_link_args,
                         depends = ["ABCGI.pyx",
                                    "Python.pxi",
                                    "numpy.pxi",
                                    "c_numpy.pxd",
                                    "CoreFoundation.pxi",
                                    "CoreGraphics.pxi",
                                    "CoreText.pxi",
                                    ]
                         )

    config.add_extension('CTFont',
                         [generate_c_from_cython],
                         extra_link_args = extra_link_args,
                         depends=["CTFont.pyx",
                                  "CoreFoundation.pxi",
                                  "CoreGraphics.pxi",
                                  "CoreText.pxi",
                                  ],
                        )

    config.add_extension("mac_context",
                         ["mac_context.c", "mac_context_cocoa.m"],
                         include_dirs = include_dirs,
                         extra_link_args = extra_link_args,
                         depends = ["mac_context.h"],
                         )

    wx_info = get_info('wx')
    if wx_info:
        wx_release = '2.6'
        for macro, value in wx_info['define_macros']:
            if macro.startswith('WX_RELEASE_'):
                wx_release = macro[len('WX_RELEASE_'):].replace('_', '.')
                break

        # only build macport for wxPython version 2.6, it's not needed in the
        # newer releases (see __init__.py)
        if wx_release == '2.6':
            macport_cpp = config.paths('macport26.cpp')[0]

            def get_macport_cpp(extension, build_dir):
                if sys.platform != 'darwin':
                    print 'No %s will be built for this platform.'%(extension.name)
                    return None
    
                elif wx_release not in ('2.6', '2.8'):
                    print ('No %s will be built because we do not recognize '
                           'wx version %s' % (extension.name, wx_release))
                    return None
    
                return macport_cpp
    
            info = {}
            dict_append(info, define_macros=[("__WXMAC__", 1)])
            dict_append(info, **wx_info)
            config.add_extension('macport', [get_macport_cpp],
                                 depends = [macport_cpp],
                                 **wx_info
                                 )
    return config