diff options
| author | David Cournapeau <cournape@gmail.com> | 2009-07-01 08:42:48 +0000 |
|---|---|---|
| committer | David Cournapeau <cournape@gmail.com> | 2009-07-01 08:42:48 +0000 |
| commit | 8a36ae9ed4459e1a45a2656afeb862b5c96ce3f6 (patch) | |
| tree | 45a6c9f6d978b9b267de528a5accbb1c455c6f33 /numpy/distutils/command | |
| parent | 9f69bfcd158873090facfba9e60ebb6d5dbb98f1 (diff) | |
| download | numpy-8a36ae9ed4459e1a45a2656afeb862b5c96ce3f6.tar.gz | |
Add check_type functionality to numpy.distutils.
Diffstat (limited to 'numpy/distutils/command')
| -rw-r--r-- | numpy/distutils/command/config.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/distutils/command/config.py b/numpy/distutils/command/config.py index 00821d260..dbf8e77a1 100644 --- a/numpy/distutils/command/config.py +++ b/numpy/distutils/command/config.py @@ -166,6 +166,35 @@ int main() return self.try_compile(body, headers, include_dirs) + def check_type(self, type_name, headers=None, include_dirs=None, + library_dirs=None): + """Check type availability. Return True if the type can be compiled, + False otherwise""" + self._check_compiler() + + # First check the type can be compiled + body = r""" +int main() { + if ((%(name)s *) 0) + return 0; + if (sizeof (%(name)s)) + return 0; +} +""" % {'name': type_name} + + st = False + try: + try: + self._compile(body % {'type': type_name}, + headers, include_dirs, 'c') + st = True + except distutils.errors.CompileError, e: + st = False + finally: + self._clean() + + return st + def check_type_size(self, type_name, headers=None, include_dirs=None, library_dirs=None, expected=None): """Check size of a given type.""" self._check_compiler() |
