From 035f66ec0f260628424c9621aed97f7cbf35e737 Mon Sep 17 00:00:00 2001 From: Marcel Loose <loose@astron.nl> Date: Fri, 14 Feb 2025 13:27:04 +0000 Subject: [PATCH] Add missing script --- Docker/get_scm_version.sh | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 Docker/get_scm_version.sh diff --git a/Docker/get_scm_version.sh b/Docker/get_scm_version.sh new file mode 100755 index 00000000..ba421a79 --- /dev/null +++ b/Docker/get_scm_version.sh @@ -0,0 +1,35 @@ +#!/bin/bash -e +# +# shellcheck disable=SC1091 +# +# Get version information from the Git repository, using the python package +# `setuptools_scm`. + +# Determine top-level directory of the repository, and change directory to it. +ROOT=$(git -C "$(dirname "${0}")" rev-parse --show-toplevel) +cd "${ROOT}" + +# Check if module `setuptools_scm` is avaible. +if ! python3 -c "import setuptools_scm" 2>/dev/null +then + # Are we inside a virtual environment? + if [ -z "${VIRTUAL_ENV}" ] + then + # Activate virtual environment if it exists in `venv` directory, + # else create one first. + if ! [ -r "venv/bin/activate" ] + then + python3 -m venv venv + fi + . venv/bin/activate + fi + # Check again if module `setuptools_scm` is avaible, now in the virtualenv + # If not, install it + if ! python3 -c "import setuptools_scm" 2>/dev/null + then + pip install --disable-pip-version-check --quiet --require-virtualenv setuptools_scm + fi +fi + +# Run the command to get the version information +python3 -c "from setuptools_scm import get_version; print(get_version())" -- GitLab