summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Papior Andersen <nickpapior@gmail.com>2015-02-23 14:37:11 +0000
committerNick Papior Andersen <nickpapior@gmail.com>2015-02-23 14:37:11 +0000
commit63e0f6ac81b8bfabc74a441dbf08eeaead091fbb (patch)
treed9b7093b352dd1d2e2b724cd767000a9ce0003fa
parent8b44a5522628cae522f00985b4ac7b3f6c21fb18 (diff)
downloadnumpy-63e0f6ac81b8bfabc74a441dbf08eeaead091fbb.tar.gz
BLD, ENH: Reading of extra flags from site.cfg to extend flexibility
Addition to the distutils module to be able to read in more optional arguments and flags from the site.cfg file. Currently are these additional options read: runtime_library_dirs: It allows users to set the runtime library directories so that LD_LIBRARY_PATH can be ignored. This has the same format as the library_dirs option. extra_compile_args: This allows the user to add specific compiler flags when compiling sources. There will be no formatting/checking of these additional compile flags, the compiler should complain if something is wrong. extra_link_args: This allows the user to add specific linker flags when linking the .so objects. There will be no formatting/checking of these additional compile flags, the linker should complain if something is wrong. When the config is runned it automatically prints out the read in information, thereby allowing the user to see what has been set and what has not. Tested with and without flags to check that it builds correctly.
-rw-r--r--numpy/distutils/system_info.py47
1 files changed, 44 insertions, 3 deletions
diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py
index d73aef59f..43a1bf2ec 100644
--- a/numpy/distutils/system_info.py
+++ b/numpy/distutils/system_info.py
@@ -198,6 +198,7 @@ if sys.platform == 'win32':
default_lib_dirs = ['C:\\',
os.path.join(distutils.sysconfig.EXEC_PREFIX,
'libs')]
+ default_runtime_dirs = []
default_include_dirs = []
default_src_dirs = ['.']
default_x11_lib_dirs = []
@@ -205,6 +206,7 @@ if sys.platform == 'win32':
else:
default_lib_dirs = libpaths(['/usr/local/lib', '/opt/lib', '/usr/lib',
'/opt/local/lib', '/sw/lib'], platform_bits)
+ default_runtime_dirs = []
default_include_dirs = ['/usr/local/include',
'/opt/include', '/usr/include',
# path of umfpack under macports
@@ -254,6 +256,7 @@ if os.path.join(sys.prefix, 'lib') not in default_lib_dirs:
default_src_dirs.append(os.path.join(sys.prefix, 'src'))
default_lib_dirs = [_m for _m in default_lib_dirs if os.path.isdir(_m)]
+default_runtime_dirs = [_m for _m in default_runtime_dirs if os.path.isdir(_m)]
default_include_dirs = [_m for _m in default_include_dirs if os.path.isdir(_m)]
default_src_dirs = [_m for _m in default_src_dirs if os.path.isdir(_m)]
@@ -470,8 +473,11 @@ class system_info(object):
defaults = {}
defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)
defaults['include_dirs'] = os.pathsep.join(default_include_dirs)
+ defaults['runtime_library_dirs'] = os.pathsep.join(default_runtime_dirs)
defaults['src_dirs'] = os.pathsep.join(default_src_dirs)
defaults['search_static_first'] = str(self.search_static_first)
+ defaults['extra_compile_args'] = []
+ defaults['extra_link_args'] = []
self.cp = ConfigParser(defaults)
self.files = []
self.files.extend(get_standard_file('.numpy-site.cfg'))
@@ -489,8 +495,9 @@ class system_info(object):
self.cp.add_section(self.section)
def calc_libraries_info(self):
- libs = self.get_libraries()
- dirs = self.get_lib_dirs()
+ libs = self.get_libraries()
+ dirs = self.get_lib_dirs()
+ r_dirs = self.get_runtime_lib_dirs()
info = {}
for lib in libs:
i = self.check_libs(dirs, [lib])
@@ -498,17 +505,46 @@ class system_info(object):
dict_append(info, **i)
else:
log.info('Library %s was not found. Ignoring' % (lib))
+ i = self.check_libs(r_dirs, [lib])
+ if i is not None:
+ # Swap library keywords found to runtime_library_dirs
+ # the libraries are insisting on the user having defined
+ # them using the library_dirs, and not necessarily by
+ # runtime_library_dirs
+ del i['libraries']
+ i['runtime_library_dirs'] = i.pop('library_dirs')
+ dict_append(info, **i)
+ else:
+ log.info('Runtime library %s was not found. Ignoring' % (lib))
return info
def set_info(self, **info):
if info:
lib_info = self.calc_libraries_info()
dict_append(info, **lib_info)
+ # Update extra information
+ extra_info = self.calc_extra_info()
+ dict_append(info, **extra_info)
self.saved_results[self.__class__.__name__] = info
def has_info(self):
return self.__class__.__name__ in self.saved_results
+ def calc_extra_info(self):
+ """ Updates the information in the current information with
+ respect to these flags:
+ extra_compile_args
+ extra_link_args
+ """
+ info = {}
+ for key in ['extra_compile_args','extra_link_args']:
+ # Get values
+ opt = self.cp.get(self.section, key)
+ if opt:
+ tmp = { key : [opt] }
+ dict_append(info,**tmp)
+ return info
+
def get_info(self, notfound_action=0):
""" Return a dictonary with items that are compatible
with numpy.distutils.setup keyword arguments.
@@ -603,6 +639,9 @@ class system_info(object):
def get_lib_dirs(self, key='library_dirs'):
return self.get_paths(self.section, key)
+ def get_runtime_lib_dirs(self, key='runtime_library_dirs'):
+ return self.get_paths(self.section, key)
+
def get_include_dirs(self, key='include_dirs'):
return self.get_paths(self.section, key)
@@ -2290,7 +2329,9 @@ def dict_append(d, **kws):
languages.append(v)
continue
if k in d:
- if k in ['library_dirs', 'include_dirs', 'define_macros']:
+ if k in ['library_dirs', 'include_dirs',
+ 'extra_compile_args', 'extra_link_args',
+ 'runtime_library_dirs', 'define_macros']:
[d[k].append(vv) for vv in v if vv not in d[k]]
else:
d[k].extend(v)