summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Bridon <bochecha@daitauha.fr>2017-09-26 19:39:41 +0200
committerMathieu Bridon <bochecha@daitauha.fr>2017-09-29 13:30:05 +0200
commit4a29f7eb2c53cd3d06038d3cbb44d1ce835de647 (patch)
treebb3375debca7fd2da0af6b23ae4a2767483e697e
parente8beece45b7de0ee0de4db2254a4e40b44bc8b58 (diff)
downloadbuildstream-fix-pyc-timestamps.tar.gz
Fix timestamps in Python bytecodefix-pyc-timestamps
When building Python modules, a bytecode `.pyc` file is generated from the source `.py` file. The former contains 4 bytes representing the timestamp of the latter at the time it was generated. Unfortunately, after building OSTree sets all the file timestamps to 0, which introduces a discrepency between the timestamp of the `.py` file and the 4 bytes stored inside the `.pyc` file. As a result, when running a Python module from a checkout, Python thinks the bytecode files are stale, which causes a dramatic performance penalty when starting an application. Fixes #94
-rw-r--r--buildstream/data/projectconfig.yaml5
-rw-r--r--buildstream/plugins/elements/distutils.yaml2
-rw-r--r--buildstream/plugins/elements/pip.yaml2
3 files changed, 9 insertions, 0 deletions
diff --git a/buildstream/data/projectconfig.yaml b/buildstream/data/projectconfig.yaml
index 6406f1609..2e47aa87b 100644
--- a/buildstream/data/projectconfig.yaml
+++ b/buildstream/data/projectconfig.yaml
@@ -120,6 +120,11 @@ variables:
strip --remove-section=.comment --remove-section=.note --strip-unneeded "$1"
objcopy --add-gnu-debuglink "$debugfile" "$1"' - {} ';'
+ fix-pyc-timestamps: |
+
+ find "%{install-root}" -name '*.pyc' \
+ -exec dd if=/dev/zero of={} bs=1 count=4 seek=4 conv=notrunc ';'
+
# Base sandbox environment, can be overridden by plugins
environment:
diff --git a/buildstream/plugins/elements/distutils.yaml b/buildstream/plugins/elements/distutils.yaml
index 3a8b119fc..7cb6f3a8d 100644
--- a/buildstream/plugins/elements/distutils.yaml
+++ b/buildstream/plugins/elements/distutils.yaml
@@ -45,3 +45,5 @@ config:
strip-commands:
- |
%{strip-binaries}
+ - |
+ %{fix-pyc-timestamps}
diff --git a/buildstream/plugins/elements/pip.yaml b/buildstream/plugins/elements/pip.yaml
index 797c608a1..19a226e00 100644
--- a/buildstream/plugins/elements/pip.yaml
+++ b/buildstream/plugins/elements/pip.yaml
@@ -22,3 +22,5 @@ config:
strip-commands:
- |
%{strip-binaries}
+ - |
+ %{fix-pyc-timestamps}