summaryrefslogtreecommitdiffstats
path: root/package/python3
diff options
context:
space:
mode:
authorJérôme Pouiller <jezz@sysmic.org>2016-12-20 14:46:24 +0100
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2017-03-20 23:03:18 +0100
commit3adbdb63e29ed9a666e3c24a5533f6da3fe932a7 (patch)
tree99732c8c7a697498db3ee9b749afb3020cf0ace5 /package/python3
parentedbe7e815ec55117ed58a70d8a8f7f5d9848b5eb (diff)
downloadbuildroot-3adbdb63e29ed9a666e3c24a5533f6da3fe932a7.tar.gz
buildroot-3adbdb63e29ed9a666e3c24a5533f6da3fe932a7.zip
python3: generate reproducible .pyc
.pyc files contain the modification time of the corresponding .py source. In order to make the build reproducible, we fix the modification time of all .py before compiling .pyc files. In addition, since pycompile relies on the modification time to know if a file needs to be recompiled, it is safer to force recompilation of all source files. This work was sponsored by `BA Robotic Systems'. Signed-off-by: Jérôme Pouiller <jezz@sysmic.org> Reviewed-by: Samuel Martin <s.martin49@gmail.com> [Thomas: do not register PYTHON_FIX_TIME as a PYTHON_TARGET_FINALIZE_HOOKS, instead call it inside PYTHON_CREATE_PYC_FILES before doing the byte compilation.] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'package/python3')
-rw-r--r--package/python3/python3.mk10
1 files changed, 9 insertions, 1 deletions
diff --git a/package/python3/python3.mk b/package/python3/python3.mk
index c8f8e1bf04..7bd6405b5d 100644
--- a/package/python3/python3.mk
+++ b/package/python3/python3.mk
@@ -237,10 +237,18 @@ PYTHON3_PATH = $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/sysconfigdat
$(eval $(autotools-package))
$(eval $(host-autotools-package))
+ifeq ($(BR2_REPRODUCIBLE),y)
+define PYTHON3_FIX_TIME
+ find $(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR) -name '*.py' -print0 | \
+ xargs -0 --no-run-if-empty touch -d @$(SOURCE_DATE_EPOCH)
+endef
+endif
+
define PYTHON3_CREATE_PYC_FILES
+ $(PYTHON3_FIX_TIME)
PYTHONPATH="$(PYTHON3_PATH)" \
$(HOST_DIR)/usr/bin/python$(PYTHON3_VERSION_MAJOR) \
- support/scripts/pycompile.py \
+ support/scripts/pycompile.py $(if $(BR2_REPRODUCIBLE),--force) \
$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)
endef
OpenPOWER on IntegriCloud