blob: 23ae5e509de22718c9978a111472e9f4b19df225 [file] [log] [blame]
Brad Bishop26bdd442019-08-16 17:08:17 -04001From 5464d9e1bfd1a1c54338ec7c4148cad1b222ef93 Mon Sep 17 00:00:00 2001
Brad Bishop316dfdd2018-06-25 12:45:53 -04002From: Martin Jansa <Martin.Jansa@gmail.com>
3Date: Tue, 24 Apr 2012 18:45:14 +0200
4Subject: [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
33Upstream-Status: Inappropriate [embedded specific]
34
35Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
36Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Brad Bishop26bdd442019-08-16 17:08:17 -040037
Brad Bishop316dfdd2018-06-25 12:45:53 -040038---
Brad Bishop26bdd442019-08-16 17:08:17 -040039 SConstruct | 8 +++++---
40 1 file changed, 5 insertions(+), 3 deletions(-)
Brad Bishop316dfdd2018-06-25 12:45:53 -040041
42diff --git a/SConstruct b/SConstruct
Brad Bishop26bdd442019-08-16 17:08:17 -040043index b8f3fb1..883e06d 100644
Brad Bishop316dfdd2018-06-25 12:45:53 -040044--- a/SConstruct
45+++ b/SConstruct
Brad Bishop26bdd442019-08-16 17:08:17 -040046@@ -980,7 +980,7 @@ else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040047
48 # Set up configuration for target Python
49
50-PYTHON_LIBDIR_CALL = 'sysconfig.get_python_lib()'
51+PYTHON_LIBDIR_CALL = 'sysconfig.get_python_lib(plat_specific=1)'
52
53 PYTHON_CONFIG_NAMES = ['CC', 'CXX', 'OPT', 'BASECFLAGS',
54 'CCSHARED', 'LDSHARED', 'SO', 'INCLUDEPY', 'LDFLAGS']
Brad Bishop26bdd442019-08-16 17:08:17 -040055@@ -1506,7 +1506,7 @@ else:
Brad Bishop316dfdd2018-06-25 12:45:53 -040056 LINK=ldshared,
57 SHLIBPREFIX="",
58 SHLIBSUFFIX=python_config['SO'],
59- CPPPATH=[python_config['INCLUDEPY']],
60+ CPPPATH=[os.path.normpath("%s/%s/%s/%s" % (env['sysroot'], env['prefix'], env['includedir'], python_config['INCLUDEPY']))] if env['sysroot'] else [python_config['INCLUDEPY']],
61 CPPFLAGS=python_config['OPT'],
62 CFLAGS=python_config['BASECFLAGS'],
63 CXXFLAGS=python_config['BASECFLAGS'])
Brad Bishop26bdd442019-08-16 17:08:17 -040064@@ -1808,12 +1808,14 @@ if ((not env['debug'] and not env['profiling'] and not env['nostrip'] and
65 env.AddPostAction(binaryinstall, '$STRIP $TARGET')
66
67 if env['python']:
68- python_module_dir = str(python_libdir) + os.sep + 'gps'
69+ python_module_dir = python_libdir.replace(env['sysroot'], '') + os.sep + 'gps'
Brad Bishop316dfdd2018-06-25 12:45:53 -040070 python_extensions_install = python_env.Install(DESTDIR + python_module_dir,
71 python_built_extensions)
Brad Bishop26bdd442019-08-16 17:08:17 -040072 if ((not env['debug'] and not env['profiling'] and
73 not env['nostrip'] and not sys.platform.startswith('darwin'))):
Brad Bishop316dfdd2018-06-25 12:45:53 -040074 python_env.AddPostAction(python_extensions_install, '$STRIP $TARGET')
75+ env.AddPostAction(python_extensions_install, '$CHRPATH -r "%s" "$TARGET"' \
76+ % (python_libdir, ))
77
78 python_modules_install = python_env.Install(DESTDIR + python_module_dir,
79 python_modules)