@@ -20,21 +20,24 @@ import os
20
20
from os .path import join as pjoin
21
21
import platform
22
22
23
+
23
24
def subdictionary (d , keyset ):
24
25
return dict (kv for kv in d .items () if kv [0 ] in keyset )
25
26
27
+
26
28
def getsyspaths (* names ):
27
29
pall = sum ((os .environ .get (n , '' ).split (os .pathsep ) for n in names ), [])
28
30
rv = [p for p in pall if os .path .exists (p )]
29
31
return rv
30
32
33
+
31
34
# copy system environment variables related to compilation
32
35
DefaultEnvironment (ENV = subdictionary (os .environ , '''
33
36
PATH CPATH CPLUS_INCLUDE_PATH LIBRARY_PATH LD_RUN_PATH
34
37
LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH
35
38
MACOSX_DEPLOYMENT_TARGET
36
39
''' .split ())
37
- )
40
+ )
38
41
39
42
# Create construction environment
40
43
env = DefaultEnvironment ().Clone ()
@@ -45,6 +48,8 @@ env.EnsureSConsVersion(0, 98, 1)
45
48
# Customizable compile variables
46
49
vars = Variables ('sconsvars.py' )
47
50
51
+ # TODO: also amend paths when VIRTUAL_ENV variable exists,
52
+ # if CONDA_PREFIX does not exist ?
48
53
if 'CONDA_PREFIX' in os .environ :
49
54
# building for a conda environment
50
55
vars .Add (PathVariable (
@@ -56,18 +61,18 @@ if 'CONDA_PREFIX' in os.environ:
56
61
vars .Add (PathVariable (
57
62
'libdir' ,
58
63
'installation directory for compiled library [prefix/Library/lib]' ,
59
- pjoin (env ['prefix' ],'Library' , 'Lib' ),
64
+ pjoin (env ['prefix' ], 'Library' , 'Lib' ),
60
65
PathVariable .PathAccept ))
61
66
vars .Add (PathVariable (
62
67
'includedir' ,
63
68
'installation directory for C++ header files [prefix/Library/include]' ,
64
- pjoin (env ['prefix' ],'Library' , 'include' ),
69
+ pjoin (env ['prefix' ], 'Library' , 'include' ),
65
70
PathVariable .PathAccept ))
66
71
else :
67
72
vars .Add (PathVariable (
68
73
'libdir' ,
69
74
'installation directory for compiled library [prefix/lib]' ,
70
- pjoin (env ['prefix' ], 'Lib ' ),
75
+ pjoin (env ['prefix' ], 'lib ' ),
71
76
PathVariable .PathAccept ))
72
77
vars .Add (PathVariable (
73
78
'includedir' ,
@@ -111,22 +116,27 @@ env.Help(MY_SCONS_HELP % vars.GenerateHelpText(env))
111
116
if platform .system ().lower () == "windows" :
112
117
# See https://scons.org/faq.html#Linking_on_Windows_gives_me_an_error
113
118
env ['ENV' ]['TMP' ] = os .environ ['TMP' ]
114
- # the CPPPATH directories are checked by scons dependency scanner
115
- cpppath = getsyspaths ('CPLUS_INCLUDE_PATH' , 'CPATH' )
116
- env .AppendUnique (CPPPATH = cpppath )
117
- # Insert LIBRARY_PATH explicitly because some compilers
118
- # ignore it in the system environment.
119
- env .PrependUnique (LIBPATH = getsyspaths ('LIBRARY_PATH' ))
120
- if 'CONDA_PREFIX' in os .environ :
121
- env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ],'include' ))
122
- env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ],'Library' ,'include' ))
123
- env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ],'Library' ,'lib' ))
124
- # This disable automated versioned named e.g. libboost_date_time-vc142-mt-s-x64-1_73.lib
125
- # so we can use conda-installed libraries
126
- env .AppendUnique (CPPDEFINES = 'BOOST_ALL_NO_LIB' )
127
119
# Prevent the generation of an import lib (.lib) in addition to the dll
128
120
# Unused as we are using as static library for windows
129
121
# env.AppendUnique(no_import_lib=1)
122
+ if 'CONDA_PREFIX' in os .environ :
123
+ env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'include' ))
124
+ env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'Library' , 'include' ))
125
+ env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'Library' , 'lib' ))
126
+ else :
127
+ if 'CONDA_PREFIX' in os .environ :
128
+ env .Append (CPPPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'include' ))
129
+ env .Append (LIBPATH = pjoin (os .environ ['CONDA_PREFIX' ], 'lib' ))
130
+
131
+ # the CPPPATH directories are checked by scons dependency scanner
132
+ cpppath = getsyspaths ('CPLUS_INCLUDE_PATH' , 'CPATH' )
133
+ env .AppendUnique (CPPPATH = cpppath )
134
+ # Insert LIBRARY_PATH explicitly because some compilers
135
+ # ignore it in the system environment.
136
+ env .PrependUnique (LIBPATH = getsyspaths ('LIBRARY_PATH' ))
137
+ # This disable automated versioned named e.g. libboost_date_time-vc142-mt-s-x64-1_73.lib
138
+ # so we can use conda-installed libraries
139
+ env .AppendUnique (CPPDEFINES = 'BOOST_ALL_NO_LIB' )
130
140
131
141
builddir = env .Dir ('build/%s-%s' % (env ['build' ], platform .machine ()))
132
142
0 commit comments