File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
nemo_retriever/src/nemo_retriever Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -249,3 +249,6 @@ outputs/
249249models /
250250
251251nemo_retriever /run_results /
252+
253+ # Ephemeral stamp file used to keep version deterministic across pip build subprocesses
254+ .build_stamp
Original file line number Diff line number Diff line change 1212from pathlib import Path
1313import os
1414import subprocess
15+ import tempfile
1516
1617try :
1718 from ._build_info import BUILD_DATE as _PACKAGE_BUILD_DATE
2324
2425_PKG_NAME = "nemo-retriever"
2526_UNKNOWN = "unknown"
27+ _BUILD_STAMP = Path (tempfile .gettempdir ()) / ".nemo_retriever_build_stamp"
2628
2729
2830def _utc_now () -> datetime :
@@ -57,7 +59,28 @@ def _build_datetime() -> datetime:
5759 except ValueError :
5860 pass
5961
60- return _utc_now ()
62+ # Stamp file in the system temp dir makes the timestamp deterministic
63+ # across the two separate subprocesses pip spawns during a PEP 517 build
64+ # (metadata + wheel). We use tempdir rather than the source tree because
65+ # pip may copy the source to different locations for each step.
66+ if _BUILD_STAMP .exists ():
67+ try :
68+ cached = _BUILD_STAMP .read_text ().strip ()
69+ if cached :
70+ ts = float (cached )
71+ # Only reuse if less than 60 s old to avoid stale stamps.
72+ if abs (_utc_now ().timestamp () - ts ) < 60 :
73+ return datetime .fromtimestamp (ts , tz = timezone .utc )
74+ _BUILD_STAMP .unlink (missing_ok = True )
75+ except (OSError , ValueError ):
76+ pass
77+
78+ now = _utc_now ()
79+ try :
80+ _BUILD_STAMP .write_text (str (now .timestamp ()))
81+ except OSError :
82+ pass
83+ return now
6184
6285
6386@lru_cache (maxsize = 1 )
You can’t perform that action at this time.
0 commit comments