scons: support py3k in python configuration detection
This commit is contained in:
parent
2840097822
commit
a741d43698
1 changed files with 30 additions and 9 deletions
21
SConstruct
21
SConstruct
|
@ -936,15 +936,36 @@ if not preconfigured:
|
|||
color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON'])
|
||||
Exit(1)
|
||||
|
||||
res = os.popen('''%s -c "print 1"''' % env['PYTHON'])
|
||||
if res.read() == '1':
|
||||
py3 = False
|
||||
else:
|
||||
py3 = True
|
||||
#sys.version_info.major == 3
|
||||
|
||||
if py3:
|
||||
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
|
||||
else:
|
||||
sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON']
|
||||
env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
|
||||
|
||||
if HAS_DISTUTILS:
|
||||
if py3:
|
||||
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON']
|
||||
else:
|
||||
sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON']
|
||||
env['PYTHON_VERSION'] = call(sys_version)
|
||||
|
||||
if py3:
|
||||
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON']
|
||||
else:
|
||||
py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON']
|
||||
env['PYTHON_INCLUDES'] = call(py_includes)
|
||||
|
||||
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
|
||||
if py3:
|
||||
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON']
|
||||
else:
|
||||
site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON']
|
||||
env['PYTHON_SITE_PACKAGES'] = call(site_packages)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue