From 59a210a2921868c2fdff6625b89f200c2c469d59 Mon Sep 17 00:00:00 2001
From: Mark Harfouche <mark.harfouche@gmail.com>
Date: Sun, 16 Feb 2025 02:04:10 +0100
Subject: [PATCH 2/2] Allow to specify git sha through environment variable
---
setup.py | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/setup.py b/setup.py
index aae3ed4..05426f1 100644
@@ -19,23 +19,9 @@ ROOT_DIR = Path(__file__).absolute().parent
def get_and_write_version():
with open(ROOT_DIR / "version.txt") as f:
version = f.readline().strip()
- sha = "Unknown"
-
- try:
- sha = (
- subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=str(ROOT_DIR))
- .decode("ascii")
- .strip()
- )
- except Exception:
- pass
-
- if os.getenv("BUILD_VERSION"):
- version = os.getenv("BUILD_VERSION")
- elif sha != "Unknown":
- version += "+" + sha[:7]
-
- version = version.replace("+cpu", "")
+
+ sha = os.getenv("BUILD_GIT_SHA", "Unknown")
+ version = os.getenv("BUILD_VERSION")
with open(ROOT_DIR / "torchvision_extra_decoders/version.py", "w") as f:
f.write(f"__version__ = '{version}'\n")
--
2.43.0