Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathSConscript
More file actions
Latest commit
108 lines (99 loc) · 5.1 KB
/
Copy pathSConscript
File metadata and controls
108 lines (99 loc) · 5.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# -*- python -*-
# Copyright Jim Bosch 2010-2012.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Big thanks to Mike Jarvis for help with the configuration prescriptions below.
# Integration of SConsChecks for platform independent building
# by Christoph Lassner.
from __future__ importprint_function
importos
importsys
importsubprocess
importsysconfig
fromSCons.SConfimportCheckContext
fromSConsChecksimportAddLibOptions, GetLibChecks
_libs= ['boost.python',
'python',
'numpy']
_checks=GetLibChecks(_libs)
# Setup command-line options
defsetupOptions():
AddOption("--prefix", dest="prefix", type="string", nargs=1, action="store",
metavar="DIR", default="/usr/local", help="installation prefix")
AddOption("--install-headers", dest="install_headers", type="string", nargs=1, action="store",
metavar="DIR", help="location to install header files (overrides --prefix for headers)")
AddOption("--install-lib", dest="install_lib", type="string", nargs=1, action="store",
metavar="DIR", help="location to install libraries (overrides --prefix for libraries)")
AddOption("--with-boost", dest="boost_prefix", type="string", nargs=1, action="store",
metavar="DIR", default=os.environ.get("BOOST_DIR"),
help="prefix for Boost libraries; should have 'include' and 'lib' subdirectories, 'boost' and 'stage\\lib' subdirectories on Windows")
AddOption("--with-boost-include", dest="boost_include", type="string", nargs=1, action="store",
metavar="DIR", help="location of Boost header files")
AddOption("--with-boost-lib", dest="boost_lib", type="string", nargs=1, action="store",
metavar="DIR", help="location of Boost libraries")
AddOption("--rpath", dest="custom_rpath", type="string", action="append",
help="runtime link paths to add to libraries and executables; may be passed more than once")
AddOption("--boost-python-lib", dest="boost_python_lib", type="string", action="store",
help="name of boost_python_lib", default='boost_python')
variables=Variables()
defaultflags="-O2 -g"
ifos.name=='nt':
defaultflags="/O2"
variables.Add("CCFLAGS", default=os.environ.get("CCFLAGS", defaultflags), help="compiler flags")
returnvariables
defmakeEnvironment(variables):
shellEnv= {}
forkeyin ("PATH", "LD_LIBRARY_PATH", "DYLD_LIBRARY_PATH", "PYTHONPATH"):
ifkeyinos.environ:
shellEnv[key] =os.environ[key]
env=Environment(variables=variables, ENV=shellEnv)
if"CCFLAGS"inos.environ:
env.AppendUnique(CCFLAGS=os.environ["CCFLAGS"])
custom_rpath=GetOption("custom_rpath")
ifcustom_rpathisnotNone:
env.AppendUnique(RPATH=custom_rpath)
ifenv['CC'] =='cl':
# C++ exception handling,
# multithread-supporting, dynamically linked system libraries,
# generate debug information.
env.AppendUnique(CPPFLAGS=['/EHsc', '/MD', '/Zi'])
returnenv
defsetupTargets(env, root="."):
# Determine file extensions.
VERSION=sys.version_info.major
ifos.name=='nt':
EXT_SUFFIX='.dll'
LIB_SUFFIX='.lib'
PY_SUFFIX='.pyd'
else:
EXT_SUFFIX=sysconfig.get_config_var("EXT_SUFFIX")
ifVERSION==2andEXT_SUFFIX=='None'orEXT_SUFFIX==None:
EXT_SUFFIX='.so'
elifVERSION==3andEXT_SUFFIX==b'None'orEXT_SUFFIX==None:
EXT_SUFFIX='.so'
LIB_SUFFIX=EXT_SUFFIX
PY_SUFFIX=EXT_SUFFIX
OBJ_SUFFIX=EXT_SUFFIX.replace ('.so', '.os')
lib=SConscript(os.path.join(root, "libs", "numpy", "src", "SConscript"),
exports=['env', 'EXT_SUFFIX', 'LIB_SUFFIX', 'OBJ_SUFFIX'])
example=SConscript(os.path.join(root, "libs", "numpy", "example", "SConscript"),
exports='env')
test=SConscript(os.path.join(root, "libs", "numpy", "test", "SConscript"),
exports=['env', 'lib', 'EXT_SUFFIX', 'LIB_SUFFIX', 'OBJ_SUFFIX', 'PY_SUFFIX'])
prefix=Dir(GetOption("prefix")).abspath
install_headers=GetOption('install_headers')
install_lib=GetOption('install_lib')
ifnotinstall_headers:
install_headers=os.path.join(prefix, "include")
ifnotinstall_lib:
install_lib=os.path.join(prefix, "lib")
env.Alias("install", env.Install(install_lib, lib))
forheaderin ("dtype.hpp", "invoke_matching.hpp", "matrix.hpp",
"ndarray.hpp", "numpy_object_mgr_traits.hpp",
"scalars.hpp", "ufunc.hpp",):
env.Alias("install", env.Install(os.path.join(install_headers, "boost", "numpy"),
os.path.join(root, "boost", "numpy", header)))
env.Alias("install", env.Install(os.path.join(install_headers, "boost"),
os.path.join(root, "boost", "numpy.hpp")))
Return("setupOptions", "makeEnvironment", "setupTargets", "_checks", "_libs")