cd01ccfbdbfca1c55f4711b2a49fe2c45dba83c4
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / python3 / 003-sysconfigdata-install-location.patch
1 Change the install location of _sysconfigdata.py
2
3 The _sysconfigdata.py module contains definitions that are needed when
4 building Python modules. In cross-compilation mode, when building
5 Python extensions for the target, we need to use the _sysconfigdata.py
6 of the target Python while executing the host Python.
7
8 However until now, the _sysconfigdata.py module was installed in
9 build/lib.<arch>-<version> directory, together with a number of
10 architecture-specific shared objects, which cannot be used with the
11 host Python.
12
13 To solve this problem, this patch moves _sysconfigdata.py to a
14 separate location, build/sysconfigdata.<arch>-<version>/, and only
15 this directory gets added to the PYTHONPATH of the host Python
16 interpreter when building Python modules for the target.
17
18 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
19
20 Index: b/Makefile.pre.in
21 ===================================================================
22 --- a/Makefile.pre.in
23 +++ b/Makefile.pre.in
24 @@ -559,6 +559,9 @@
25                 rm -f ./pybuilddir.txt ; \
26                 exit 1 ; \
27         fi
28 +       echo `cat pybuilddir.txt`/sysconfigdata > pysysconfigdatadir.txt
29 +       mkdir -p `cat pysysconfigdatadir.txt`
30 +       cp `cat pybuilddir.txt`/_sysconfigdata.py `cat pysysconfigdatadir.txt`
31  
32  # Build the shared modules
33  # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
34 @@ -1197,7 +1200,7 @@
35                 else    true; \
36                 fi; \
37         done
38 -       @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py; \
39 +       @for i in $(srcdir)/Lib/*.py ; \
40         do \
41                 if test -x $$i; then \
42                         $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
43 @@ -1207,6 +1210,11 @@
44                         echo $(INSTALL_DATA) $$i $(LIBDEST); \
45                 fi; \
46         done
47 +       $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
48 +               $(DESTDIR)$(LIBDEST)
49 +       mkdir -p $(DESTDIR)$(LIBDEST)/sysconfigdata
50 +       $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
51 +               $(DESTDIR)$(LIBDEST)/sysconfigdata
52         @for d in $(LIBSUBDIRS); \
53         do \
54                 a=$(srcdir)/Lib/$$d; \
55 @@ -1533,7 +1541,7 @@
56         find build -name 'fficonfig.h' -exec rm -f {} ';' || true
57         find build -name '*.py' -exec rm -f {} ';' || true
58         find build -name '*.py[co]' -exec rm -f {} ';' || true
59 -       -rm -f pybuilddir.txt
60 +       -rm -f pybuilddir.txt pysysconfigdatadir.txt
61         -rm -f Lib/lib2to3/*Grammar*.pickle
62         -rm -f Modules/_testembed Modules/_freeze_importlib
63  
64 Index: b/configure.ac
65 ===================================================================
66 --- a/configure.ac
67 +++ b/configure.ac
68 @@ -70,7 +70,7 @@
69             AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
70         fi
71          AC_MSG_RESULT($interp)
72 -       PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
73 +       PYTHON_FOR_BUILD='_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pysysconfigdatadir.txt && echo $(abs_builddir)/`cat pysysconfigdatadir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) '$interp
74      fi
75  elif test "$cross_compiling" = maybe; then
76      AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])