From 764b40d13f851bdc8c10f8eb0f06f232aa363f93 Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Mon, 12 Feb 2018 17:51:09 -0500 Subject: [PATCH] [patch] Implemented gps package installation to python 2 AND 3 Signed-off-by: Daniel_M_Williams --- SConstruct | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 3fa5bd7..11fd665 100644 --- a/SConstruct +++ b/SConstruct @@ -588,8 +588,9 @@ def CheckC11(context): def GetPythonValue(context, name, imp, expr, brief=False): - context.Message('Obtaining Python %s... ' % name) - context.sconf.cached = 0 # Avoid bogus "(cached)" + if context: + context.Message('Obtaining Python %s... ' % name) + context.sconf.cached = 0 # Avoid bogus "(cached)" if not env['target_python']: status, value = 0, str(eval(expr)) else: @@ -605,7 +606,10 @@ def GetPythonValue(context, name, imp, expr, brief=False): value = '' announce("Python command failed - disabling Python.") env['python'] = False - context.Result('failed' if status else 'ok' if brief else value) + + if context: + context.Result('failed' if status else 'ok' if brief else value) + return value @@ -616,7 +620,7 @@ def GetLoadPath(context): cleaning = env.GetOption('clean') helping = env.GetOption('help') -config = Configure(env, custom_tests={ +config = Configure( env, custom_tests={ 'CheckPKG': CheckPKG, 'CheckXsltproc': CheckXsltproc, 'CheckCompilerOption': CheckCompilerOption, @@ -1320,6 +1324,7 @@ if not env['python']: python_built_extensions = [] python_targets = [] python_progs = [] + env['python3'] = False else: python_progs = ["gpscat", "gpsfake", "gpsprof", "gegps"] if env['xgps']: @@ -1417,6 +1422,29 @@ Platform: UNKNOWN python_built_extensions = list(python_compiled_libs.values()) python_targets = python_built_extensions + [python_egg_info] + # if the system python is 2 and python 3 *also* exists, install as well. + if 2 == sys.version_info[0]: + + py3_config = Configure(python_env) + target_python_path = py3_config.CheckProg("python3") + # py3_config.Finish() + + if python_env.get('python3', True) and bool(target_python_path): + # print("____>> Also found python3. Assembling package....!!") + env['python3'] = True + env['python3_path'] = target_python_path + python3_libdir = GetPythonValue( None, + 'lib dir', + PYTHON_SYSCONFIG_IMPORT, + PYTHON_LIBDIR_CALL, + brief=True ) + env['python3_libdir'] = python3_libdir + python_env['python3_libdir'] = python3_libdir + + # print("____>> python3_libdir: " + str(python3_libdir)) + + + env.Command(target="packet_names.h", source="packet_states.h", action=""" rm -f $TARGET &&\ sed -e '/^ *\([A-Z][A-Z0-9_]*\),/s// \"\\1\",/' <$SOURCE >$TARGET &&\ @@ -1702,6 +1730,33 @@ else: # install, but we do need it for the uninstall Dir(DESTDIR + python_module_dir)] +if env['python3']: + python_module_dir = str( python3_libdir ) + os.sep + 'gps' + + python_extensions_install = python_env.Install( DESTDIR + python_module_dir, + python_built_extensions ) + if ((not env['debug'] and not env['profiling'] + and not env['nostrip'] and not sys.platform.startswith( 'darwin' ))): + python_env.AddPostAction( python_extensions_install, '$STRIP $TARGET' ) + + python_modules_install = python_env.Install( DESTDIR + python_module_dir, + python_modules ) + + python_progs_install = python_env.Install( installdir( 'bindir' ), + python_progs ) + + python_egg_info_install = python_env.Install( DESTDIR + str( python3_libdir ), + python_egg_info ) + + python_install += [python_extensions_install, + python_modules_install, + python_progs_install, + python_egg_info_install, + # We don't need the directory explicitly for the + # install, but we do need it for the uninstall + Dir(DESTDIR + python_module_dir)] + + pc_install = [env.Install(installdir('pkgconfig'), 'libgps.pc')] if qt_env: pc_install.append(qt_env.Install(installdir('pkgconfig'), 'Qgpsmm.pc')) -- 2.7.4