From 6f254e688e0a431cb066bee16faca75442894170 Mon Sep 17 00:00:00 2001 From: Sylvain Tricot Date: Wed, 26 Oct 2022 17:15:24 +0200 Subject: [PATCH] Change the version mechanism --- src/msspec.sh.template | 9 ++++++--- src/msspec/version.py | 15 ++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/msspec.sh.template b/src/msspec.sh.template index 38cdfca..bb250fb 100644 --- a/src/msspec.sh.template +++ b/src/msspec.sh.template @@ -2,12 +2,11 @@ SCRIPT_PATH="$0" SCRIPT_NAME=$(basename "$SCRIPT_PATH") -VERSION="__VERSION__" VENV_PATH="__VENV_PATH__" # Check venv path if ! [ -d "$VENV_PATH" ]; then - echo "ERROR: Unable to find version $VERSION of msspec!!" + echo "ERROR: Unable to find msspec!!" exit 1 fi @@ -15,6 +14,10 @@ launch_script() { . "$VENV_PATH/bin/activate" && python "$@" } +show_version () { + . "$VENV_PATH/bin/activate" && python -c "import msspec; print(msspec.__version__)" +} + show_help () { echo "Usage: 1) $SCRIPT_NAME -p [PYTHON OPTIONS] SCRIPT [ARGUMENTS...]" echo " 2) $SCRIPT_NAME [-l FILE | -i | -h]" @@ -92,7 +95,7 @@ while getopts "hvil:p:eu" option; do ;; u) uninstall ;; - v) echo $VERSION + v) show_version ;; *|h) show_help ;; diff --git a/src/msspec/version.py b/src/msspec/version.py index 7e6ff1a..bcd00c0 100644 --- a/src/msspec/version.py +++ b/src/msspec/version.py @@ -17,12 +17,13 @@ # along with this msspec. If not, see . # # Source file : src/msspec/version.py -# Last modified: Thu, 06 Oct 2022 18:27:24 +0200 -# Committed by : Sylvain Tricot 1665073644 +0200 +# Last modified: Wed, 26 Oct 2022 17:15:24 +0200 +# Committed by : Sylvain Tricot 1666797324 +0200 import os +from setuptools_scm import get_version from importlib.metadata import version import subprocess @@ -34,14 +35,10 @@ import subprocess PKGNAME = 'msspec' try: - __version__ = version(PKGNAME) + __version__ = get_version(root='../..', relative_to=__file__) except Exception as err: try: - p = subprocess.run(["git", "describe"], capture_output=True, text=True) - if p.stdout not in ("", None): - __version__ = p.stdout.strip() - else: - raise NameError("git describe failed!") + __version__ = version(PKGNAME) except Exception as err: try: thisfile_path = os.path.abspath(__file__) @@ -51,4 +48,4 @@ except Exception as err: __version__ = fd.readline().strip() except Exception as err: print("Unable to get the version number!") - __version__ = "9.9.9" + __version__ = "0.0.0"