Skip to content

Commit

Permalink
Add ADD_PYTHON_SYS_FLAGS option (specifically add ability to turn it …
Browse files Browse the repository at this point in the history
…off)
  • Loading branch information
rmjarvis committed Nov 23, 2018
1 parent c986962 commit 1443bce
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ opts.Add(BoolVariable('IMPORT_PATHS',
False))
opts.Add(BoolVariable('IMPORT_ENV',
'Import full environment from calling shell',True))
opts.Add(BoolVariable('ADD_PYTHON_SYS_FLAGS','Add compile and link flags from sysconfig',True))
opts.Add('EXTRA_LIBS','Libraries to send to the linker','')
opts.Add(BoolVariable('IMPORT_PREFIX',
'Use PREFIX/include and PREFIX/lib in search paths', True))
Expand Down Expand Up @@ -1382,15 +1383,16 @@ PyMODINIT_FUNC initcheck_python(void)
"""
config.Message('Checking if we can build against Python... ')

# Check if we need to add any additional linking flags according to what is given in
# sysconfig.get_config_var("LDSHARED"). cf. Issue #924
sys_builder = distutils.sysconfig.get_config_var("LDSHARED")
ldflags = sys_builder.split()
ldflags = ldflags[1:] # strip off initial gcc or cc
config.env.Replace(LDMODULEFLAGS=['$LINKFLAGS'] + ldflags)
# Need this too to get consistency, e.g. with --arch options.
ccflags = distutils.sysconfig.get_config_var("CCSHARED")
config.env.Append(CCFLAGS=ccflags.split())
if config.env['ADD_PYTHON_SYS_FLAGS']:
# Check if we need to add any additional linking flags according to what is given in
# sysconfig.get_config_var("LDSHARED"). cf. Issue #924
sys_builder = distutils.sysconfig.get_config_var("LDSHARED")
ldflags = sys_builder.split()
ldflags = ldflags[1:] # strip off initial gcc or cc
config.env.Replace(LDMODULEFLAGS=['$LINKFLAGS'] + ldflags)
# Need this too to get consistency, e.g. with --arch options.
ccflags = distutils.sysconfig.get_config_var("CCSHARED")
config.env.Append(CCFLAGS=ccflags.split())

# First check the python include directory -- see if we can compile the module.
source_file2 = "import distutils.sysconfig; print(distutils.sysconfig.get_python_inc())"
Expand Down

0 comments on commit 1443bce

Please sign in to comment.