Do not fail if VERSION.sha not found (#579)

* Create VERSION.sha file while creating standalone binary

* Do not fail on VERSION.sha not found

* Add git to docker container for testing

[ROCm/rocprofiler-compute commit: 19a9365bb9]
This commit is contained in:
vedithal-amd
2025-02-26 11:39:37 -05:00
کامیت شده توسط GitHub
والد 4a890ce8d0
کامیت 2fc811bbbd
4فایلهای تغییر یافته به همراه23 افزوده شده و 20 حذف شده
@@ -381,6 +381,8 @@ add_custom_target(
COMMAND ${Python3_EXECUTABLE} -m pip list | grep -i nuitka > /dev/null 2>&1
# Check patchelf
COMMAND ${Python3_EXECUTABLE} -m pip list | grep -i patchelf > /dev/null 2>&1
# Create VERSION.sha file
COMMAND git -C ${PROJECT_SOURCE_DIR} rev-parse HEAD > VERSION.sha
# Build standalone binary
COMMAND
${Python3_EXECUTABLE} -m nuitka --mode=onefile
@@ -2,7 +2,10 @@ FROM redhat/ubi8:8.10-1184
WORKDIR /app
RUN yum install -y curl gcc cmake
RUN yum install -y curl gcc cmake git
# Allows running git commands in /app
RUN git config --global --add safe.directory /app
RUN yum install -y python38 python38-devel && \
yum clean all && \
@@ -6,10 +6,13 @@ WORKDIR /app
# Update package list and install prerequisites
RUN apt-get update && apt-get install -y \
software-properties-common cmake locales \
software-properties-common cmake locales git \
&& add-apt-repository ppa:deadsnakes/ppa \
&& apt-get update
# Allows running git commands in /app
RUN git config --global --add safe.directory /app
# Generate the desired locale
RUN locale-gen en_US.UTF-8
@@ -118,29 +118,24 @@ def get_version(rocprof_compute_home) -> dict:
console_error("Cannot find VERSION file at {}".format(searchDirs))
# git version info
gitDir = str(path(rocprof_compute_home.parent).joinpath(".git"))
if (shutil.which("git") is not None) and path(gitDir).exists():
gitQuery = subprocess.run(
["git", "log", "--pretty=format:%h", "-n", "1"],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
try:
success, output = capture_subprocess_output(
["git", "-C", versionDir, "log", "--pretty=format:%h", "-n", "1"],
)
if gitQuery.returncode != 0:
SHA = "unknown"
MODE = "unknown"
else:
SHA = gitQuery.stdout.decode("utf-8")
if success:
SHA = output
MODE = "dev"
else:
shaFile = str(path(versionDir).joinpath("VERSION.sha"))
else:
raise Exception(output)
except:
try:
shaFile = path(versionDir).joinpath("VERSION.sha").absolute().resolve()
with open(shaFile, "r") as file:
SHA = file.read().replace("\n", "")
except EnvironmentError:
console_error("Cannot find VERSION.sha file at {}".format(shaFile))
sys.exit(1)
MODE = "release"
MODE = "release"
except Exception:
SHA = "unknown"
MODE = "unknown"
versionData = {"version": VER, "sha": SHA, "mode": MODE}
return versionData