476f5fc8f6
The major changes in terms of Buildroot packaging are: - Due to PEP488, Python no longer generates .pyc (unoptimized) and .pyo (optimized) byte-code files. Instead, it generates <foo>.pyc, <foo>.opt-1.pyc and <foo>.opt-2.pyc. Therefore, we removed the --disable-pyo-build option and kept only the --disable-pyc-build option, which completely disables building all .pyc files. In addition, since the optimized .opt-X.pyc files don't work if the corresponding un-optimized .pyc file is not present, we are for the moment unconditionally removing the optimized ones (keeping both the unoptimized and optimized ones doubles the required filesystem size!). So basically we preserve the behavior we had before this commit: BR2_PACKAGE_PYTHON3_PY_ONLY -> only *.py BR2_PACKAGE_PYTHON3_PYC_ONLY -> only non-optimized *.pyc BR2_PACKAGE_PYTHON3_PY_PYC -> both the *.py and non-optimized *.pyc To achieve this, the TARGET_FINALIZE_HOOKS are reworked: PYTHON3_REMOVE_PY_FILES is responsible for removing *.py files in the BR2_PACKAGE_PYTHON3_PYC_ONLY case. PYTHON3_REMOVE_PYC_FILES is responsible for removing *.pyc files in the BR2_PACKAGE_PYTHON3_PY_ONLY case. PYTHON3_REMOVE_OPTIMIZED_PYC_FILES is responsible for removing the optimized *.opt-1.pyc and *.opt-2.pyc files, which is done unconditionally. - The PEP3147 disabling patch had to be significantly reworked due to the code having changed heavily. The code was moved into a _bootstrap_external.py, which is a "frozen" Python module, i.e a module generated into a .h file at compile time using the _freeze_importlib program. - Due to the above, we now need to regenerate importlib.h at build time. Unfortunately, for the target Python _freeze_importlib is built for the target, so we can't run it on the build machine. To fix this, we copy the _freeze_importlib program from the host-python in $(HOST_DIR), and then patch the target python to use it. Since the same solution can be used for 'pgen', we do it, and avoid having to touch the graminit.{c,h} files. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Reviewed-by: Samuel Martin <s.martin49@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
87 lines
3.6 KiB
Diff
87 lines
3.6 KiB
Diff
From 4ac038d30ec71b3f223ac7c91613856dd82b6347 Mon Sep 17 00:00:00 2001
|
|
From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
|
Date: Wed, 23 Dec 2015 11:29:04 +0100
|
|
Subject: [PATCH] Change the install location of _sysconfigdata.py
|
|
|
|
The _sysconfigdata.py module contains definitions that are needed when
|
|
building Python modules. In cross-compilation mode, when building
|
|
Python extensions for the target, we need to use the _sysconfigdata.py
|
|
of the target Python while executing the host Python.
|
|
|
|
However until now, the _sysconfigdata.py module was installed in
|
|
build/lib.<arch>-<version> directory, together with a number of
|
|
architecture-specific shared objects, which cannot be used with the
|
|
host Python.
|
|
|
|
To solve this problem, this patch moves _sysconfigdata.py to a
|
|
separate location, build/sysconfigdata.<arch>-<version>/, and only
|
|
this directory gets added to the PYTHONPATH of the host Python
|
|
interpreter when building Python modules for the target.
|
|
|
|
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
|
---
|
|
Makefile.pre.in | 12 ++++++++++--
|
|
configure.ac | 2 +-
|
|
2 files changed, 11 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/Makefile.pre.in b/Makefile.pre.in
|
|
index 823def3..4d2a061 100644
|
|
--- a/Makefile.pre.in
|
|
+++ b/Makefile.pre.in
|
|
@@ -585,6 +585,9 @@ pybuilddir.txt: $(BUILDPYTHON)
|
|
rm -f ./pybuilddir.txt ; \
|
|
exit 1 ; \
|
|
fi
|
|
+ echo `cat pybuilddir.txt`/sysconfigdata > pysysconfigdatadir.txt
|
|
+ mkdir -p `cat pysysconfigdatadir.txt`
|
|
+ cp `cat pybuilddir.txt`/_sysconfigdata.py `cat pysysconfigdatadir.txt`
|
|
|
|
# Build the shared modules
|
|
# Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
|
|
@@ -1235,7 +1238,7 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
|
|
else true; \
|
|
fi; \
|
|
done
|
|
- @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py; \
|
|
+ @for i in $(srcdir)/Lib/*.py ; \
|
|
do \
|
|
if test -x $$i; then \
|
|
$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
|
|
@@ -1245,6 +1248,11 @@ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
|
|
echo $(INSTALL_DATA) $$i $(LIBDEST); \
|
|
fi; \
|
|
done
|
|
+ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
|
|
+ $(DESTDIR)$(LIBDEST)
|
|
+ mkdir -p $(DESTDIR)$(LIBDEST)/sysconfigdata
|
|
+ $(INSTALL_DATA) `cat pysysconfigdatadir.txt`/_sysconfigdata.py \
|
|
+ $(DESTDIR)$(LIBDEST)/sysconfigdata
|
|
@for d in $(LIBSUBDIRS); \
|
|
do \
|
|
a=$(srcdir)/Lib/$$d; \
|
|
@@ -1580,7 +1588,7 @@ clean: pycremoval
|
|
find build -name 'fficonfig.h' -exec rm -f {} ';' || true
|
|
find build -name '*.py' -exec rm -f {} ';' || true
|
|
find build -name '*.py[co]' -exec rm -f {} ';' || true
|
|
- -rm -f pybuilddir.txt
|
|
+ -rm -f pybuilddir.txt pysysconfigdatadir.txt
|
|
-rm -f Lib/lib2to3/*Grammar*.pickle
|
|
-rm -f Programs/_testembed Programs/_freeze_importlib
|
|
-rm -rf build
|
|
diff --git a/configure.ac b/configure.ac
|
|
index 694293e..76b70a0 100644
|
|
--- a/configure.ac
|
|
+++ b/configure.ac
|
|
@@ -70,7 +70,7 @@ if test "$cross_compiling" = yes; then
|
|
AC_MSG_ERROR([python$PACKAGE_VERSION interpreter not found])
|
|
fi
|
|
AC_MSG_RESULT($interp)
|
|
- 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
|
|
+ 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
|
|
fi
|
|
elif test "$cross_compiling" = maybe; then
|
|
AC_MSG_ERROR([Cross compiling required --host=HOST-TUPLE and --build=ARCH])
|
|
--
|
|
2.6.4
|
|
|