summaryrefslogtreecommitdiff
path: root/package/python/python-2.7-020-gentoo_py_dontcompile.patch
blob: 276f0e6f43e19fc2af4f81a7f46f54fe4d3e4c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
This patch purpose is to allow not to save the generated python bytecode in
a file for later use through the PYTHON_DONTCOMPILE environment variable.

I do not see the use of it, because you can choose if you want but it seems
somewhat related to gentoo.

Maybe useful when the generated rootfs is mounted on read-only on the target.

Patch ported to python2.7 by Maxime Ripard <ripard@archos.com>

diff -rduNp Python-2.7.orig/Python/import.c Python-2.7/Python/import.c
--- Python-2.7.orig/Python/import.c	2010-09-30 12:05:53.000000000 +0200
+++ Python-2.7/Python/import.c	2010-09-30 12:20:38.000000000 +0200
@@ -886,7 +886,12 @@ write_compiled_module(PyCodeObject *co,
     mode_t mode = srcstat->st_mode & ~S_IXUSR & ~S_IXGRP & ~S_IXOTH;
 #endif
 
-    fp = open_exclusive(cpathname, mode);
+    char *py_dontcompile = getenv("PYTHON_DONTCOMPILE");
+
+    if (!py_dontcompile)
+      fp = open_exclusive(cpathname, mode);
+    else
+      fp = NULL;
     if (fp == NULL) {
         if (Py_VerboseFlag)
             PySys_WriteStderr(