Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 1e2cea8945bc2183fbe1a012dcd633a352125952 Mon Sep 17 00:00:00 2001 |
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | Date: Tue, 24 Apr 2012 18:45:14 +0200 |
| 4 | Subject: [PATCH] SConstruct: prefix includepy with sysroot and drop sysroot |
| 5 | from python_lib_dir |
| 6 | |
| 7 | * without PYTHONPATH, distutil's sysconfig returns INCLUDEPY without sysroot prefix |
| 8 | and with PYTHONPATH from OE it's pointing to native python dir |
| 9 | |
| 10 | $ export PYTHONPATH=/OE/shr-core/tmp-eglibc/sysroots/om-gta02/usr/lib/python2.7/ |
| 11 | $ python |
| 12 | Python 2.7.2 (default, Apr 18 2012, 09:19:59) |
| 13 | [GCC 4.6.2] on linux2 |
| 14 | Type "help", "copyright", "credits" or "license" for more information. |
| 15 | >>> from distutils import sysconfig |
| 16 | >>> sysconfig.get_config_vars('INCLUDEPY') |
| 17 | ['/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include/python2.7'] |
| 18 | >>> |
| 19 | $ unset PYTHONPATH |
| 20 | $ python |
| 21 | Python 2.7.2 (default, Apr 18 2012, 09:19:59) |
| 22 | [GCC 4.6.2] on linux2 |
| 23 | Type "help", "copyright", "credits" or "license" for more information. |
| 24 | >>> from distutils import sysconfig |
| 25 | >>> sysconfig.get_config_vars('INCLUDEPY') |
| 26 | ['/python2.7'] |
| 27 | >>> import sysconfig |
| 28 | >>> sysconfig.get_config_vars('INCLUDEPY') |
| 29 | ['/OE/shr-core/tmp-eglibc/sysroots/x86_64-linux/usr/include/python2.7'] |
| 30 | * python_lib_dir = python_lib_dir.replace(env['sysroot'], '') |
| 31 | returns path to target sysroot |
| 32 | |
| 33 | Upstream-Status: Inappropriate [embedded specific] |
| 34 | |
| 35 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 36 | Signed-off-by: Peter A. Bigot <pab@pabigot.com> |
| 37 | --- |
| 38 | SConstruct | 9 +++++++++ |
| 39 | 1 file changed, 9 insertions(+) |
| 40 | |
| 41 | diff --git a/SConstruct b/SConstruct |
| 42 | index 6c93311..cde8b3d 100644 |
| 43 | --- a/SConstruct |
| 44 | +++ b/SConstruct |
| 45 | @@ -1148,6 +1148,12 @@ else: |
| 46 | basecflags += ' -coverage' |
| 47 | ldflags += ' -coverage' |
| 48 | ldshared += ' -coverage' |
| 49 | + |
| 50 | + if env['sysroot']: |
| 51 | + print "Prefixing includepy '%s' with sysroot prefix" % includepy |
| 52 | + includepy = os.path.normpath("%s/%s/%s/%s" % (env['sysroot'], env['prefix'], env['includedir'], includepy)) |
| 53 | + print "'%s'" % includepy |
| 54 | + |
| 55 | # in case CC/CXX was set to the scan-build wrapper, |
| 56 | # ensure that we build the python modules with scan-build, too |
| 57 | if env['CC'] is None or env['CC'].find('scan-build') < 0: |
| 58 | @@ -1408,11 +1414,14 @@ if not env['python']: |
| 59 | python_install = [] |
| 60 | else: |
| 61 | python_lib_dir = env['python_libdir'] |
| 62 | + python_lib_dir = python_lib_dir.replace(env['sysroot'], '') |
| 63 | python_module_dir = python_lib_dir + os.sep + 'gps' |
| 64 | python_extensions_install = python_env.Install( DESTDIR + python_module_dir, |
| 65 | python_built_extensions) |
| 66 | if not env['debug'] and not env['profiling'] and not env['nostrip'] and not sys.platform.startswith('darwin'): |
| 67 | python_env.AddPostAction(python_extensions_install, '$STRIP $TARGET') |
| 68 | + env.AddPostAction(python_extensions_install, '$CHRPATH -r "%s" "$TARGET"' \ |
| 69 | + % (python_lib_dir, )) |
| 70 | |
| 71 | python_modules_install = python_env.Install( DESTDIR + python_module_dir, |
| 72 | python_modules) |
| 73 | -- |
| 74 | 2.1.0 |
| 75 | |