summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2025-09-26 16:19:12 +0800
committerKhem Raj <raj.khem@gmail.com>2025-10-03 11:21:05 -0700
commitc8a1d7b83c3cbebeff73a837eae0045700608cb7 (patch)
tree7697a5b0eaa5a534659754ba98b858b83e427064
parent07a2308e4f859b584cbaeb6a4ec480a7c2677a84 (diff)
downloadmeta-openembedded-c8a1d7b83c3cbebeff73a837eae0045700608cb7.tar.gz
python3-mlcommons-loadgen: support reproducibility
Implement the SOURCE_DATE_EPOCH specification[1] for reproducible builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the current time. [1] https://reproducible-builds.org/specs/source-date-epoch/ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch41
-rw-r--r--meta-python/recipes-devtools/python3-mlcommons-loadgen/python3-mlcommons-loadgen_5.1.0.bb4
2 files changed, 45 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch b/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch
new file mode 100644
index 0000000000..32e529d483
--- /dev/null
+++ b/meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch
@@ -0,0 +1,41 @@
1From dd7925397b84c2a327cd4594edba9f7ca5acef61 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Fri, 26 Sep 2025 14:02:23 +0800
4Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable
5
6Implement the SOURCE_DATE_EPOCH specification[1] for reproducible
7builds. If SOURCE_DATE_EPOCH is set, use it as timestamp instead of the
8current time.
9
10[1] https://reproducible-builds.org/specs/source-date-epoch/
11
12Upstream-Status: Submitted [https://github.com/mlcommons/inference/pull/2345]
13
14Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
15---
16 version_generator.py | 9 +++++++--
17 1 file changed, 7 insertions(+), 2 deletions(-)
18
19diff --git a/version_generator.py b/version_generator.py
20index 2e75243..5202da9 100644
21--- a/version_generator.py
22+++ b/version_generator.py
23@@ -110,8 +110,13 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root):
24 # Write the version into the function definition
25 ofile.write(func_def("Version", f"\"{version_contents}\""))
26
27- date_time_now_local = datetime.datetime.now().isoformat()
28- date_time_now_utc = datetime.datetime.utcnow().isoformat()
29+ if os.environ.get('SOURCE_DATE_EPOCH', False):
30+ source_date_epoch = int(os.environ['SOURCE_DATE_EPOCH'])
31+ date_time_now_local = datetime.datetime.fromtimestamp(source_date_epoch).isoformat()
32+ date_time_now_utc = datetime.datetime.fromtimestamp(source_date_epoch, tz=datetime.timezone.utc).isoformat()
33+ else:
34+ date_time_now_local = datetime.datetime.now().isoformat()
35+ date_time_now_utc = datetime.datetime.utcnow().isoformat()
36 ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"'))
37 ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"'))
38
39--
402.34.1
41
diff --git a/meta-python/recipes-devtools/python3-mlcommons-loadgen/python3-mlcommons-loadgen_5.1.0.bb b/meta-python/recipes-devtools/python3-mlcommons-loadgen/python3-mlcommons-loadgen_5.1.0.bb
index abc47172c1..7bb2e9d4dd 100644
--- a/meta-python/recipes-devtools/python3-mlcommons-loadgen/python3-mlcommons-loadgen_5.1.0.bb
+++ b/meta-python/recipes-devtools/python3-mlcommons-loadgen/python3-mlcommons-loadgen_5.1.0.bb
@@ -14,6 +14,10 @@ DEPENDS = "python3-pybind11-native"
14 14
15inherit setuptools3 pypi 15inherit setuptools3 pypi
16 16
17SRC_URI += " \
18 file://source-date-epoch.patch \
19"
20
17PYPI_PACKAGE = "mlcommons_loadgen" 21PYPI_PACKAGE = "mlcommons_loadgen"
18UPSTREAM_CHECK_PYPI_PACKAGE = "mlcommons_loadgen" 22UPSTREAM_CHECK_PYPI_PACKAGE = "mlcommons_loadgen"
19 23