python-2.7-020-gentoo_py_dontcompile.patch 1.0 KB

123456789101112131415161718192021222324252627
  1. This patch purpose is to allow not to save the generated python bytecode in
  2. a file for later use through the PYTHON_DONTCOMPILE environment variable.
  3. I do not see the use of it, because you can choose if you want but it seems
  4. somewhat related to gentoo.
  5. Maybe useful when the generated rootfs is mounted on read-only on the target.
  6. Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>
  7. diff -rduNp Python-2.7.orig/Python/import.c Python-2.7/Python/import.c
  8. --- Python-2.7.orig/Python/import.c 2010-09-30 12:05:53.000000000 +0200
  9. +++ Python-2.7/Python/import.c 2010-09-30 12:20:38.000000000 +0200
  10. @@ -886,7 +886,12 @@ write_compiled_module(PyCodeObject *co,
  11. mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
  12. #endif
  13. - fp = open_exclusive(cpathname, mode);
  14. + char *py_dontcompile = getenv("PYTHON_DONTCOMPILE");
  15. +
  16. + if (!py_dontcompile)
  17. + fp = open_exclusive(cpathname, mode);
  18. + else
  19. + fp = NULL;
  20. if (fp == NULL) {
  21. if (Py_VerboseFlag)
  22. PySys_WriteStderr(