python3-010-distutils-cross-compilation-support.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. Add some cross-compilation fixes to distutils
  2. Inspired by work done by Marc Kleine-Budde <mkl@pengutronix.de> in
  3. PTXdist.
  4. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  5. ---
  6. Lib/distutils/sysconfig.py | 17 +++++++++++++----
  7. configure.ac | 8 +++++++-
  8. 2 files changed, 20 insertions(+), 5 deletions(-)
  9. Index: Python-3.3.0/Lib/distutils/sysconfig.py
  10. ===================================================================
  11. --- Python-3.3.0.orig/Lib/distutils/sysconfig.py
  12. +++ Python-3.3.0/Lib/distutils/sysconfig.py
  13. @@ -16,15 +16,24 @@
  14. from .errors import DistutilsPlatformError
  15. # These are needed in a couple of spots, so just compute them once.
  16. -PREFIX = os.path.normpath(sys.prefix)
  17. -EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  18. +EXECUTABLE_DIRNAME = os.path.dirname(os.path.realpath(sys.executable))
  19. +if os.environ.get('CROSS_COMPILING') == 'yes':
  20. + _sysroot=os.environ.get('_python_sysroot')
  21. + PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_prefix'))
  22. + EXEC_PREFIX = os.path.normpath(_sysroot + os.environ.get('_python_exec_prefix'))
  23. + if '_python_srcdir' in os.environ:
  24. + EXECUTABLE_DIRNAME = os.path.normpath(os.environ['_python_srcdir'])
  25. +else:
  26. + PREFIX = os.path.normpath(sys.prefix)
  27. + EXEC_PREFIX = os.path.normpath(sys.exec_prefix)
  28. +
  29. BASE_PREFIX = os.path.normpath(sys.base_prefix)
  30. BASE_EXEC_PREFIX = os.path.normpath(sys.base_exec_prefix)
  31. # Path to the base directory of the project. On Windows the binary may
  32. # live in project/PCBuild9. If we're dealing with an x64 Windows build,
  33. # it'll live in project/PCbuild/amd64.
  34. -project_base = os.path.dirname(os.path.abspath(sys.executable))
  35. +project_base = EXECUTABLE_DIRNAME
  36. if os.name == "nt" and "pcbuild" in project_base[-8:].lower():
  37. project_base = os.path.abspath(os.path.join(project_base, os.path.pardir))
  38. # PC/VS7.1
  39. @@ -98,7 +107,7 @@
  40. # the build directory may not be the source directory, we
  41. # must use "srcdir" from the makefile to find the "Include"
  42. # directory.
  43. - base = _sys_home or os.path.dirname(os.path.abspath(sys.executable))
  44. + base = _sys_home or EXECUTABLE_DIRNAME
  45. if plat_specific:
  46. return base
  47. if _sys_home:
  48. Index: Python-3.3.0/configure.ac
  49. ===================================================================
  50. --- Python-3.3.0.orig/configure.ac
  51. +++ Python-3.3.0/configure.ac
  52. @@ -963,7 +963,13 @@
  53. fi
  54. if test "$cross_compiling" = yes; then
  55. - RUNSHARED=
  56. + RUNSHARED=" \
  57. + CROSS_COMPILING=yes \
  58. + _python_cross_host=${ac_cv_host} \
  59. + _python_sysroot=\"\$(sysroot)\" \
  60. + _python_srcdir=\"\$(srcdir)\" \
  61. + _python_prefix=\"\$(prefix)\" \
  62. + _python_exec_prefix=\"\$(exec_prefix)\""
  63. fi
  64. AC_MSG_RESULT($LDLIBRARY)