better checking for whether our target python is python 3
This commit is contained in:
parent
18dd9ff40e
commit
9492d309e6
2 changed files with 14 additions and 12 deletions
|
@ -199,6 +199,7 @@ def pretty_dep(dep):
|
|||
return dep
|
||||
|
||||
# local file to hold custom user configuration variables
|
||||
# Todo check timestamp, reload if changed?
|
||||
SCONS_LOCAL_CONFIG = 'config.py'
|
||||
# build log
|
||||
SCONS_LOCAL_LOG = 'config.log'
|
||||
|
@ -1093,12 +1094,7 @@ 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
|
||||
py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
|
||||
|
||||
if py3:
|
||||
sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON']
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
#
|
||||
# $Id$
|
||||
|
||||
import glob
|
||||
import re
|
||||
import os
|
||||
import os, re, sys, glob
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
|
||||
|
@ -37,6 +35,10 @@ def call(cmd, silent=True):
|
|||
def run_2to3(*args,**kwargs):
|
||||
call('2to3 -w %s' % os.path.dirname(kwargs['target'][0].path))
|
||||
|
||||
def is_py3():
|
||||
return 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip()
|
||||
|
||||
|
||||
prefix = env['PREFIX']
|
||||
target_path = env['PYTHON_INSTALL_LOCATION'] + '/mapnik2'
|
||||
|
||||
|
@ -51,6 +53,9 @@ if env['BOOST_PYTHON_LIB']:
|
|||
else:
|
||||
libraries.append(env['BOOST_PYTHON_LIB'].replace('lib','',1))
|
||||
else:
|
||||
if is_py3():
|
||||
libraries.append('boost_python3%s' % env['BOOST_APPEND'])
|
||||
else:
|
||||
libraries.append('boost_python%s' % env['BOOST_APPEND'])
|
||||
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
|
@ -199,6 +204,7 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
|
|||
pymapniklib = env.Install(target_path,_mapnik)
|
||||
py_env.Alias(target='install',source=pymapniklib)
|
||||
if pymapniklib and 'install' in COMMAND_LINE_TARGETS:
|
||||
if is_py3():
|
||||
env.AddPostAction(pymapniklib, run_2to3)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue