002-properly-detect-if-python-build.patch 1.1 KB

1234567891011121314151617181920212223
  1. distutils: fix build_ext check to find whether we're building Python or not
  2. The build_ext logic uses
  3. sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")) to
  4. determine whether we're building a third-party Python extension, or a
  5. built-in Python extension. However, this check is wrong in
  6. cross-compilation mode, and instead, the sysconfig.python_build
  7. variable should be used.
  8. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  9. Index: b/Lib/distutils/command/build_ext.py
  10. ===================================================================
  11. --- a/Lib/distutils/command/build_ext.py
  12. +++ b/Lib/distutils/command/build_ext.py
  13. @@ -237,7 +237,7 @@
  14. # Python's library directory must be appended to library_dirs
  15. # See Issues: #1600860, #4366
  16. if (sysconfig.get_config_var('Py_ENABLE_SHARED')):
  17. - if sys.executable.startswith(os.path.join(sys.exec_prefix, "bin")):
  18. + if not sysconfig.python_build:
  19. # building third party extensions
  20. self.library_dirs.append(sysconfig.get_config_var('LIBDIR'))
  21. else: