0003-Adjust-library-header-paths-for-cross-compilation.patch 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 9f58bc7a648990d89258191c39651c075ce1c1c7 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 23 Dec 2015 11:33:14 +0100
  4. Subject: [PATCH] Adjust library/header paths for cross-compilation
  5. When cross-compiling third-party extensions, the get_python_inc() or
  6. get_python_lib() can be called, to return the path to headers or
  7. libraries. However, they use the sys.prefix of the host Python, which
  8. returns incorrect paths when cross-compiling (paths pointing to host
  9. headers and libraries).
  10. In order to fix this, we introduce the _python_sysroot, _python_prefix
  11. and _python_exec_prefix variables, that allow to override these
  12. values, and get correct header/library paths when cross-compiling
  13. third-party Python modules.
  14. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  15. [ Adam Duskett: ported to Python 3.10.0 ]
  16. Signed-off-by: Adam Duskett <aduskett@gmail.com>
  17. [ Adam Duskett: ported to Python 3.12.1 ]
  18. Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
  19. ---
  20. Lib/sysconfig.py | 15 +++++++++++----
  21. 1 file changed, 11 insertions(+), 4 deletions(-)
  22. diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
  23. index 122d441bd19..a4922c429a3 100644
  24. --- a/Lib/sysconfig.py
  25. +++ b/Lib/sysconfig.py
  26. @@ -169,10 +169,17 @@ def joinuser(*args):
  27. _PY_VERSION = sys.version.split()[0]
  28. _PY_VERSION_SHORT = f'{sys.version_info[0]}.{sys.version_info[1]}'
  29. _PY_VERSION_SHORT_NO_DOT = f'{sys.version_info[0]}{sys.version_info[1]}'
  30. -_PREFIX = os.path.normpath(sys.prefix)
  31. -_BASE_PREFIX = os.path.normpath(sys.base_prefix)
  32. -_EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  33. -_BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
  34. +if "_python_sysroot" in os.environ:
  35. + _sysroot=os.environ.get('_python_sysroot')
  36. + _PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
  37. + _EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
  38. + _BASE_PREFIX = _PREFIX
  39. + _BASE_EXEC_PREFIX = _EXEC_PREFIX
  40. +else:
  41. + _PREFIX = os.path.normpath(sys.prefix)
  42. + _EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  43. + _BASE_PREFIX = os.path.normpath(sys.base_prefix)
  44. + _BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
  45. # Mutex guarding initialization of _CONFIG_VARS.
  46. _CONFIG_VARS_LOCK = threading.RLock()
  47. _CONFIG_VARS = None
  48. --
  49. 2.43.0