summaryrefslogtreecommitdiff
path: root/package/python/python-2.7-008-reread-environment.patch
blob: e36d0cf11d28e0529865bd8d0220a89f0bfc96e4 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Make sure setup.py reads the correct CONFIG_ARGS

The setup.py script that builds and installs all the Python modules
shipped with the interpreter looks at the CONFIG_ARGS variable stored
in the "sysconfig" module to look at the ./configure options and
adjust its behaviour accordingly.

Unfortunately, when cross-compiling, the value of CONFIG_ARGS returned
by the sysconfig are the one passed to the ./configure script of the
*host* Python and not the one we're currently building for the target.

In order to avoid that, we re-initialize the values in the sysconfig
module by re-reading the environment at the beginning of the setup.py
script, and we make sure that the CONFIG_ARGS variable is actually
part of the environment of setup.py.

See the beginning of
http://article.gmane.org/gmane.comp.python.devel/99772 for the
inspiration.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

---
 Makefile.pre.in |    6 +++---
 setup.py        |    3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

Index: Python-2.7.1/Makefile.pre.in
===================================================================
--- Python-2.7.1.orig/Makefile.pre.in
+++ Python-2.7.1/Makefile.pre.in
@@ -408,8 +408,8 @@
 # Build the shared modules
 sharedmods: $(BUILDPYTHON)
 	@case $$MAKEFLAGS in \
-	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \
-	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \
+	*s*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py -q build;; \
+	*) $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' OPT='$(OPT)' CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py build;; \
 	esac
 
 # Build static library
@@ -1039,7 +1039,7 @@
 # Install the dynamically loadable modules
 # This goes into $(exec_prefix)
 sharedinstall: sharedmods
-	$(RUNSHARED) CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \
+	$(RUNSHARED) CROSS_COMPILING=@CROSS_COMPILING@ DISABLED_EXTENSIONS="$(DISABLED_EXTENSIONS)" CONFIG_ARGS="$(CONFIG_ARGS)" $(PYTHON_FOR_BUILD) -E $(srcdir)/setup.py install \
 	   	--prefix=$(prefix) \
 		--install-scripts=$(BINDIR) \
 		--install-platlib=$(DESTSHARED) \
Index: Python-2.7.1/setup.py
===================================================================
--- Python-2.7.1.orig/setup.py
+++ Python-2.7.1/setup.py
@@ -20,6 +20,9 @@
 # Were we compiled --with-pydebug or with #define Py_DEBUG?
 COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
 
+sysconfig.get_config_vars()
+sysconfig._CONFIG_VARS.update(os.environ)
+
 # This global variable is used to hold the list of modules to be disabled.
 try:
     disabled_module_list = sysconfig.get_config_var("DISABLED_EXTENSIONS").split(" ")