~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to scipy/weave/base_info.py

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""
 
2
    base_info holds classes that define the information
 
3
    needed for building C++ extension modules for Python that
 
4
    handle different data types.  The information includes
 
5
    such as include files, libraries, and even code snippets.
 
6
 
 
7
    base_info -- base class for cxx_info, blitz_info, etc.
 
8
    info_list -- a handy list class for working with multiple
 
9
                 info classes at the same time.
 
10
"""
 
11
import UserList
 
12
 
 
13
class base_info(object):
 
14
    _warnings =[]
 
15
    _headers = []
 
16
    _include_dirs = []
 
17
    _libraries = []
 
18
    _library_dirs = []
 
19
    _support_code = []
 
20
    _module_init_code = []
 
21
    _sources = []
 
22
    _define_macros = []
 
23
    _undefine_macros = []
 
24
    _extra_compile_args = []
 
25
    _extra_link_args = []
 
26
    compiler = ''
 
27
    def set_compiler(self,compiler):
 
28
        self.check_compiler(compiler)
 
29
        self.compiler = compiler
 
30
    # it would probably be better to specify what the arguments are
 
31
    # to avoid confusion, but I don't think these classes will get
 
32
    # very complicated, and I don't really know the variety of things
 
33
    # that should be passed in at this point.
 
34
    def check_compiler(self,compiler):
 
35
        pass
 
36
    def warnings(self):
 
37
        return self._warnings
 
38
    def headers(self):
 
39
        return self._headers
 
40
    def include_dirs(self):
 
41
        return self._include_dirs
 
42
    def libraries(self):
 
43
        return self._libraries
 
44
    def library_dirs(self):
 
45
        return self._library_dirs
 
46
    def support_code(self):
 
47
        return self._support_code
 
48
    def module_init_code(self):
 
49
        return self._module_init_code
 
50
    def sources(self):
 
51
        return self._sources
 
52
    def define_macros(self):
 
53
        return self._define_macros
 
54
    def undefine_macros(self):
 
55
        return self._undefine_macros
 
56
    def extra_compile_args(self):
 
57
        return self._extra_compile_args
 
58
    def extra_link_args(self):
 
59
        return self._extra_link_args
 
60
 
 
61
class custom_info(base_info):
 
62
    def __init__(self):
 
63
        self._warnings =[]
 
64
        self._headers = []
 
65
        self._include_dirs = []
 
66
        self._libraries = []
 
67
        self._library_dirs = []
 
68
        self._support_code = []
 
69
        self._module_init_code = []
 
70
        self._sources = []
 
71
        self._define_macros = []
 
72
        self._undefine_macros = []
 
73
        self._extra_compile_args = []
 
74
        self._extra_link_args = []
 
75
 
 
76
    def add_warning(self,warning):
 
77
        self._warnings.append(warning)
 
78
    def add_header(self,header):
 
79
        self._headers.append(header)
 
80
    def add_include_dir(self,include_dir):
 
81
        self._include_dirs.append(include_dir)
 
82
    def add_library(self,library):
 
83
        self._libraries.append(library)
 
84
    def add_library_dir(self,library_dir):
 
85
        self._library_dirs.append(library_dir)
 
86
    def add_support_code(self,support_code):
 
87
        self._support_code.append(support_code)
 
88
    def add_module_init_code(self,module_init_code):
 
89
        self._module_init_code.append(module_init_code)
 
90
    def add_source(self,source):
 
91
        self._sources.append(source)
 
92
    def add_define_macro(self,define_macro):
 
93
        self._define_macros.append(define_macro)
 
94
    def add_undefine_macro(self,undefine_macro):
 
95
        self._undefine_macros.append(undefine_macro)
 
96
    def add_extra_compile_arg(self,compile_arg):
 
97
        return self._extra_compile_args.append(compile_arg)
 
98
    def add_extra_link_arg(self,link_arg):
 
99
        return self._extra_link_args.append(link_arg)
 
100
 
 
101
class info_list(UserList.UserList):
 
102
    def get_unique_values(self,attribute):
 
103
        all_values = []
 
104
        for info in self:
 
105
            vals = eval('info.'+attribute+'()')
 
106
            all_values.extend(vals)
 
107
        return unique_values(all_values)
 
108
 
 
109
    def extra_compile_args(self):
 
110
        return self.get_unique_values('extra_compile_args')
 
111
    def extra_link_args(self):
 
112
        return self.get_unique_values('extra_link_args')
 
113
    def sources(self):
 
114
        return self.get_unique_values('sources')
 
115
    def define_macros(self):
 
116
        return self.get_unique_values('define_macros')
 
117
    def sources(self):
 
118
        return self.get_unique_values('sources')
 
119
    def warnings(self):
 
120
        return self.get_unique_values('warnings')
 
121
    def headers(self):
 
122
        return self.get_unique_values('headers')
 
123
    def include_dirs(self):
 
124
        return self.get_unique_values('include_dirs')
 
125
    def libraries(self):
 
126
        return self.get_unique_values('libraries')
 
127
    def library_dirs(self):
 
128
        return self.get_unique_values('library_dirs')
 
129
    def support_code(self):
 
130
        return self.get_unique_values('support_code')
 
131
    def module_init_code(self):
 
132
        return self.get_unique_values('module_init_code')
 
133
 
 
134
def unique_values(lst):
 
135
    all_values = []
 
136
    for value in lst:
 
137
        if value not in all_values or value == '-framework':
 
138
            all_values.append(value)
 
139
    return all_values