scons: add fallback for contructing python install environment if distutils is not available
This commit is contained in:
parent
c6a48bfdb2
commit
727b2ee9b9
1 changed files with 22 additions and 12 deletions
34
SConstruct
34
SConstruct
|
@ -27,6 +27,12 @@ from glob import glob
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from SCons.SConf import SetCacheMode
|
from SCons.SConf import SetCacheMode
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
try:
|
||||||
|
import distutils.sysconfig
|
||||||
|
HAS_DISTUTILS = True
|
||||||
|
except:
|
||||||
|
HAS_DISTUTILS = False
|
||||||
|
|
||||||
def color_print(color,text,newline=True):
|
def color_print(color,text,newline=True):
|
||||||
# 1 - red
|
# 1 - red
|
||||||
|
@ -44,7 +50,7 @@ def call(cmd):
|
||||||
if not stderr:
|
if not stderr:
|
||||||
return stdin.strip()
|
return stdin.strip()
|
||||||
else:
|
else:
|
||||||
color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org')
|
color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr)
|
||||||
|
|
||||||
if platform.uname()[4] == 'x86_64':
|
if platform.uname()[4] == 'x86_64':
|
||||||
LIBDIR_SCHEMA='lib64'
|
LIBDIR_SCHEMA='lib64'
|
||||||
|
@ -734,19 +740,23 @@ if not env.GetOption('clean'):
|
||||||
sys_prefix = "%s -c 'import sys; print sys.prefix'" % env['PYTHON']
|
sys_prefix = "%s -c 'import sys; print sys.prefix'" % env['PYTHON']
|
||||||
env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
|
env['PYTHON_SYS_PREFIX'] = call(sys_prefix)
|
||||||
|
|
||||||
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
|
if HAS_DISTUTILS:
|
||||||
site_packages = "%s -c 'from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)'" % env['PYTHON']
|
sys_version = "%s -c 'from distutils.sysconfig import get_python_version; print get_python_version_()'" % env['PYTHON']
|
||||||
env['PYTHON_SITE_PACKAGES'] = call(site_packages)
|
env['PYTHON_VERSION'] = call(sys_version)
|
||||||
|
py_includes = "%s -c 'from distutils.sysconfig import get_python_inc; print get_python_inc()'" % env['PYTHON']
|
||||||
sys_version = "%s -c 'from distutils.sysconfig import get_python_version; print get_python_version()'" % env['PYTHON']
|
env['PYTHON_INCLUDES'] = call(py_includes)
|
||||||
env['PYTHON_VERSION'] = call(sys_version)
|
# Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location
|
||||||
|
site_packages = "%s -c 'from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)'" % env['PYTHON']
|
||||||
py_includes = "%s -c 'from distutils.sysconfig import get_python_inc; print get_python_inc()'" % env['PYTHON']
|
env['PYTHON_SITE_PACKAGES'] = call(site_packages)
|
||||||
env['PYTHON_INCLUDES'] = call(py_includes)
|
else:
|
||||||
|
env['PYTHON_SYS_PREFIX'] = os.popen("%s -c 'import sys; print sys.prefix'" % env['PYTHON']).read().strip()
|
||||||
|
env['PYTHON_VERSION'] = os.popen("%s -c 'import sys; print sys.version'" % env['PYTHON']).read()[0:3]
|
||||||
|
env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION']
|
||||||
|
env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + '/' + env['PYTHON_SYS_PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
|
||||||
|
|
||||||
# if user-requested custom prefix fall back to manual concatenation for building subdirectories
|
# if user-requested custom prefix fall back to manual concatenation for building subdirectories
|
||||||
py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
|
|
||||||
if env['PYTHON_PREFIX']:
|
if env['PYTHON_PREFIX']:
|
||||||
|
py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/'
|
||||||
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + '/' + env['PYTHON_PREFIX'] + '/' + py_relative_install
|
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + '/' + env['PYTHON_PREFIX'] + '/' + py_relative_install
|
||||||
else:
|
else:
|
||||||
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + '/' + env['PYTHON_SITE_PACKAGES']
|
env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + '/' + env['PYTHON_SITE_PACKAGES']
|
||||||
|
|
Loading…
Reference in a new issue