016-distutils-no-pep3147.patch 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Add distutils fix for PEP 3147 issue
  2. Python 3 has a new standard for installing .pyc file, called PEP
  3. 3147. Unfortunately, this standard requires both the .py and .pyc
  4. files to be installed for a Python module to be found. This is quite
  5. annoying on space-constrained embedded systems, since the .py file is
  6. technically not required for execution.
  7. For the Python standard library, our Python 3 package already contains
  8. a patch named python3-004-old-stdlib-cache.patch, which allows to
  9. disable the PEP 3147 installation.
  10. But that lives the distutils/setuptools package an unsolved
  11. problem. This patch therefore adds a new patch to Python, which makes
  12. distutils package use the traditional installation path when byte
  13. compiling, rather than the PEP 3147 installation path. Since
  14. setuptools relies on distutils internally, it also fixes setuptools
  15. based packages.
  16. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  17. Index: b/Lib/distutils/util.py
  18. ===================================================================
  19. --- a/Lib/distutils/util.py
  20. +++ b/Lib/distutils/util.py
  21. @@ -437,7 +437,9 @@
  22. # Terminology from the py_compile module:
  23. # cfile - byte-compiled file
  24. # dfile - purported source filename (same as 'file' by default)
  25. - if optimize >= 0:
  26. + if "_python_sysroot" in os.environ:
  27. + cfile = file + (__debug__ and "c" or "o")
  28. + elif optimize >= 0:
  29. cfile = importlib.util.cache_from_source(
  30. file, debug_override=not optimize)
  31. else: