source: trunk/distutils/scons_ext.py@ 2516

Last change on this file since 2516 was 2515, checked in by Malte Marquarding, 12 years ago

added forwarding of casacorestatic

File size: 3.0 KB
Line 
1import os, sys, platform
2import subprocess
3import shutil
4from distutils.command import build_ext
5
6class scons_ext(build_ext.build_ext):
7 """Build extensions using scons instead of distutils.
8 """
9 _scons_options = []
10 user_options = \
11 [('casacoreroot=', None,
12 'Prefix for casacore installation location'),
13 ('casacorestatic=', None,
14 'use static casacore libraries'),
15 ('boostroot=', None,
16 'Prefix for boost_python installation location'),
17 ('boostlib=', None, 'Name of the boost_python library'),
18 ('cfitsioroot=', None,
19 'Prefix for cfitsio installation location'),
20 ('cfitsiolib=', None, 'Name of the cfitsio library'),
21 ('wcsroot=', None, 'Prefix for wcslib installation location'),
22 ('wcslib=', None, 'Name of the wcs library'),
23 ('rpfitsroot=', None, 'Prefix for rpfits installation location'),
24 ('rpfitslib=', None, 'Name of the rpfits library'),
25 ('blaslib=', None, 'Name of the blas library'),
26 ('lapacklib=', None, 'Name of the lapack library'),
27 ('f2clib=', None, 'Name of the fortran-to-c library'),
28 ('jobs=','j', 'Number of processes'),
29 ('extraroot=', None,
30 'Extra root directory where muiltple packages could be found,'
31 ' e.g. $HOME, to add $HOME/lib etc to the build.'),
32 ]
33
34
35 def initialize_options(self):
36 """
37 Overload to enable custom settings to be picked up
38 """
39 build_ext.build_ext.initialize_options(self)
40 self._scons_options = []
41 # attribute corresponding to directory prefix
42 # command line option
43 self.jobs = None
44 self.extraroot = None
45 self.casacoreroot = None
46 self.casacorestatic = None
47 self.boostroot = None
48 self.boostlib = None
49 self.cfitsioroot = None
50 self.cfitsiolib = None
51 self.wcsroot = None
52 self.wcslib = None
53 self.rpfitsroot = None
54 self.rpfitslib = None
55 self.blaslib = None
56 self.lapacklib = None
57 self.f2clib = None
58
59 def finalize_options(self):
60 build_ext.build_ext.finalize_options(self)
61 for opt in self.user_options:
62 atr = opt[0].strip("=")
63 v = getattr(self, atr)
64 if v is not None:
65 if opt[1] is None:
66 self._scons_options.append("=".join([atr, v]))
67 else:
68 self._scons_options.append(" ".join(["-"+opt[1], v]))
69
70 def build_extensions(self):
71 ext = self.extensions[0]
72 try:
73 ext_path = self.get_ext_fullpath(ext.name)
74 extdir = os.path.dirname(ext_path)
75 except AttributeError:
76 # hack for pyhton 2.5
77 extdir = os.path.join(self.build_lib, ext.name.split(".")[0])
78 if not os.path.exists(extdir):
79 os.makedirs(extdir)
80 cmd = ['scons'] + self._scons_options
81 subprocess.call(cmd)
82 # copy extension into distutils build directory
83 if os.path.exists("build/_asap.so"):
84 shutil.copy("build/_asap.so", extdir)
Note: See TracBrowser for help on using the repository browser.