From 4b589e4099ff4b57c349ccfd6c03993a9088c653 Mon Sep 17 00:00:00 2001 From: Hongxu Jia Date: Fri, 26 Sep 2025 16:19:12 +0800 Subject: 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 Signed-off-by: Khem Raj --- .../files/source-date-epoch.patch | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch (limited to 'meta-python/recipes-devtools/python3-mlcommons-loadgen/files/source-date-epoch.patch') 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 @@ +From dd7925397b84c2a327cd4594edba9f7ca5acef61 Mon Sep 17 00:00:00 2001 +From: Hongxu Jia +Date: Fri, 26 Sep 2025 14:02:23 +0800 +Subject: [PATCH] Honor the SOURCE_DATE_EPOCH variable + +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/ + +Upstream-Status: Submitted [https://github.com/mlcommons/inference/pull/2345] + +Signed-off-by: Hongxu Jia +--- + version_generator.py | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/version_generator.py b/version_generator.py +index 2e75243..5202da9 100644 +--- a/version_generator.py ++++ b/version_generator.py +@@ -110,8 +110,13 @@ def generate_loadgen_version_definitions(cc_filename, loadgen_root): + # Write the version into the function definition + ofile.write(func_def("Version", f"\"{version_contents}\"")) + +- date_time_now_local = datetime.datetime.now().isoformat() +- date_time_now_utc = datetime.datetime.utcnow().isoformat() ++ if os.environ.get('SOURCE_DATE_EPOCH', False): ++ source_date_epoch = int(os.environ['SOURCE_DATE_EPOCH']) ++ date_time_now_local = datetime.datetime.fromtimestamp(source_date_epoch).isoformat() ++ date_time_now_utc = datetime.datetime.fromtimestamp(source_date_epoch, tz=datetime.timezone.utc).isoformat() ++ else: ++ date_time_now_local = datetime.datetime.now().isoformat() ++ date_time_now_utc = datetime.datetime.utcnow().isoformat() + ofile.write(func_def("BuildDateLocal", '"' + date_time_now_local + '"')) + ofile.write(func_def("BuildDateUtc", '"' + date_time_now_utc + '"')) + +-- +2.34.1 + -- cgit v1.2.3-54-g00ecf