blob: 06dbb4318cc1da36b335ddc0fa563ea9e59fe80b [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From e359a7a3c4f9e70360a068bef19c95938fdacede Mon Sep 17 00:00:00 2001
2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3Date: Wed, 23 Dec 2015 11:33:14 +0100
4Subject: [PATCH] Adjust library/header paths for cross-compilation
5
6When cross-compiling third-party extensions, the get_python_inc() or
7get_python_lib() can be called, to return the path to headers or
8libraries. However, they use the sys.prefix of the host Python, which
9returns incorrect paths when cross-compiling (paths pointing to host
10headers and libraries).
11
12In order to fix this, we introduce the _python_sysroot, _python_prefix
13and _python_exec_prefix variables, that allow to override these
14values, and get correct header/library paths when cross-compiling
15third-party Python modules.
16
17Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
18[adapt for setuptools, rename environment variable, use fixed lib path]
19Signed-off-by: Jeffery To <jeffery.to@gmail.com>
20---
21 Lib/distutils/command/build_ext.py | 5 ++++-
22 Lib/sysconfig.py | 15 +++++++++++----
23 2 files changed, 15 insertions(+), 5 deletions(-)
24
25--- a/setuptools/_distutils/command/build_ext.py
26+++ b/setuptools/_distutils/command/build_ext.py
27@@ -238,7 +238,10 @@ class build_ext(Command):
28 if sysconfig.get_config_var('Py_ENABLE_SHARED'):
29 if not sysconfig.python_build:
30 # building third party extensions
31- self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
32+ libdir = sysconfig.get_config_var('LIBDIR')
33+ if 'STAGING_DIR' in os.environ:
34+ libdir = os.environ.get('STAGING_DIR') + '/usr/lib'
35+ self.library_dirs.append(libdir)
36 else:
37 # building python standard extensions
38 self.library_dirs.append('.')