Chris@87
|
1 from __future__ import division, absolute_import, print_function
|
Chris@87
|
2
|
Chris@87
|
3 import os
|
Chris@87
|
4 from distutils.core import Command
|
Chris@87
|
5 from distutils.ccompiler import new_compiler
|
Chris@87
|
6 from numpy.distutils.misc_util import get_cmd
|
Chris@87
|
7
|
Chris@87
|
8 class install_clib(Command):
|
Chris@87
|
9 description = "Command to install installable C libraries"
|
Chris@87
|
10
|
Chris@87
|
11 user_options = []
|
Chris@87
|
12
|
Chris@87
|
13 def initialize_options(self):
|
Chris@87
|
14 self.install_dir = None
|
Chris@87
|
15 self.outfiles = []
|
Chris@87
|
16
|
Chris@87
|
17 def finalize_options(self):
|
Chris@87
|
18 self.set_undefined_options('install', ('install_lib', 'install_dir'))
|
Chris@87
|
19
|
Chris@87
|
20 def run (self):
|
Chris@87
|
21 build_clib_cmd = get_cmd("build_clib")
|
Chris@87
|
22 build_dir = build_clib_cmd.build_clib
|
Chris@87
|
23
|
Chris@87
|
24 # We need the compiler to get the library name -> filename association
|
Chris@87
|
25 if not build_clib_cmd.compiler:
|
Chris@87
|
26 compiler = new_compiler(compiler=None)
|
Chris@87
|
27 compiler.customize(self.distribution)
|
Chris@87
|
28 else:
|
Chris@87
|
29 compiler = build_clib_cmd.compiler
|
Chris@87
|
30
|
Chris@87
|
31 for l in self.distribution.installed_libraries:
|
Chris@87
|
32 target_dir = os.path.join(self.install_dir, l.target_dir)
|
Chris@87
|
33 name = compiler.library_filename(l.name)
|
Chris@87
|
34 source = os.path.join(build_dir, name)
|
Chris@87
|
35 self.mkpath(target_dir)
|
Chris@87
|
36 self.outfiles.append(self.copy_file(source, target_dir)[0])
|
Chris@87
|
37
|
Chris@87
|
38 def get_outputs(self):
|
Chris@87
|
39 return self.outfiles
|