diff options
| author | David Cournapeau <cournape@gmail.com> | 2009-07-26 11:04:24 +0000 |
|---|---|---|
| committer | David Cournapeau <cournape@gmail.com> | 2009-07-26 11:04:24 +0000 |
| commit | bfbb9dd7c06d85e29983fc741679761c9b769137 (patch) | |
| tree | 42b3e647c6e2db6df8aabb2324da8727fde1e0c9 | |
| parent | 78de166d5bd2a41f90defd899abb9fb6c14c6c79 (diff) | |
| download | numpy-bfbb9dd7c06d85e29983fc741679761c9b769137.tar.gz | |
Installing a clib now works.
Installable libraries are built exactly like conventional clib (they are
added to the NumpyDistribution instance libraries member, and build_clib
is not aware of the libraries/installable libraries distinction).
Everything is done in the install_clib. The library cannot be used yet
by external code, though.
| -rw-r--r-- | numpy/core/setup.py | 2 | ||||
| -rw-r--r-- | numpy/distutils/command/install_clib.py | 22 | ||||
| -rw-r--r-- | numpy/distutils/misc_util.py | 34 | ||||
| -rw-r--r-- | numpy/distutils/numpy_distribution.py | 2 |
4 files changed, 50 insertions, 10 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index d5d72dceb..8f95546de 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -578,7 +578,7 @@ def configuration(parent_package='',top_path=None): # explicitly add an extension which has generate_config_h and # generate_numpyconfig_h as sources *before* adding npymath. config.add_installed_library('npymath', - sources=[join('src', 'npymath', 'npy_math.c.src')]) + sources=[join('src', 'npymath', 'npy_math.c.src')], install_dir='numpy/core/lib') multiarray_deps = [ join('src', 'multiarray', 'arrayobject.h'), diff --git a/numpy/distutils/command/install_clib.py b/numpy/distutils/command/install_clib.py index c6934e6f8..ddb10a162 100644 --- a/numpy/distutils/command/install_clib.py +++ b/numpy/distutils/command/install_clib.py @@ -1,5 +1,6 @@ import os from distutils.core import Command +from numpy.distutils.misc_util import get_cmd class install_clib(Command): description = "Command to install installable C libraries" @@ -7,13 +8,26 @@ class install_clib(Command): user_options = [] def initialize_options(self): - pass + self.install_dir = None + self.outfiles = [] def finalize_options(self): - pass + self.set_undefined_options('install', ('install_lib', 'install_dir')) def run (self): - pass + # We need the compiler to get the library name -> filename association + from distutils.ccompiler import new_compiler + compiler = new_compiler(compiler=None) + compiler.customize(self.distribution) + + build_dir = get_cmd("build_clib").build_clib + + for l in self.distribution.installed_libraries: + target_dir = os.path.join(self.install_dir, l.target_dir) + name = compiler.library_filename(l.name) + source = os.path.join(build_dir, name) + self.mkpath(target_dir) + self.outfiles.append(self.copy_file(source, target_dir)[0]) def get_outputs(self): - return [] + return self.outfiles diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 20b414613..f3ce796b2 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -25,6 +25,12 @@ __all__ = ['Configuration', 'get_numpy_include_dirs', 'default_config_dict', 'is_sequence', 'is_string', 'as_list', 'gpaths', 'get_language', 'quote_args', 'get_build_architecture'] +class InstallableLib: + def __init__(self, name, build_info, target_dir): + self.name = name + self.build_info = build_info + self.target_dir = target_dir + def quote_args(args): # don't used _nt_quote_args as it does not check if # args items already have quotes or not. @@ -589,7 +595,8 @@ def get_frame(level=0): class Configuration(object): _list_keys = ['packages', 'ext_modules', 'data_files', 'include_dirs', - 'libraries', 'headers', 'scripts', 'py_modules', 'scons_data'] + 'libraries', 'headers', 'scripts', 'py_modules', 'scons_data', + 'installed_libraries'] _dict_keys = ['package_dir'] _extra_keys = ['name', 'version'] @@ -1190,13 +1197,30 @@ class Configuration(object): self.warn('distutils distribution has been initialized,'\ ' it may be too late to add a library '+ name) - def add_installed_library(self, name, sources, build_info=None): + def add_installed_library(self, name, sources, install_dir, build_info=None): """Add installable library to configuration. """ if not build_info: - self.add_library(name, sources) - else: - self.add_library(name, sources, **build_info) + build_info = {} + # self.add_library(name, sources) + #else: + # self.add_library(name, sources, **build_info) + + build_info = copy.copy(build_info) + name = name #+ '__OF__' + self.name + build_info['sources'] = sources + + # Sometimes, depends is not set up to an empty list by default, and if + # depends is not given to add_library, distutils barfs (#1134) + if not build_info.has_key('depends'): + build_info['depends'] = [] + + self._fix_paths_dict(build_info) + + # Add to libraries list so that it is build with build_clib + self.libraries.append((name, build_info)) + self.installed_libraries.append(InstallableLib(name, build_info, install_dir)) + def add_sconscript(self, sconscript, subpackage_path=None, standalone = False, pre_hook = None, diff --git a/numpy/distutils/numpy_distribution.py b/numpy/distutils/numpy_distribution.py index 681b8b316..3e855b9c3 100644 --- a/numpy/distutils/numpy_distribution.py +++ b/numpy/distutils/numpy_distribution.py @@ -7,6 +7,8 @@ class NumpyDistribution(Distribution): def __init__(self, attrs = None): # A list of (sconscripts, pre_hook, post_hook, src, parent_names) self.scons_data = [] + # A list of installable libraries + self.installed_libraries = [] Distribution.__init__(self, attrs) def has_scons_scripts(self): |
