From 01839bf7d4afe82766d6684bb6a8adf5242318fd Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:59:59 +0000 Subject: [PATCH] [bugfix] Update version configurations (backport #5771) (#5772) Co-authored-by: Hailin Wang --- pyproject.toml | 2 -- src/abqpy/__init__.py | 17 ++++++----------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 86e39c707e..aa8d5cb4d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -93,9 +93,7 @@ abqpy = "abqpy.__main__:main" where = ["src"] [tool.setuptools_scm] -version_scheme = "guess-next-dev" write_to = "src/abqpy/_version.py" -fallback_version = "2023.0.0-dev" [tool.pytest.ini_options] testpaths = ["src", "tests"] diff --git a/src/abqpy/__init__.py b/src/abqpy/__init__.py index 65f01aa280..70e31a4eda 100644 --- a/src/abqpy/__init__.py +++ b/src/abqpy/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations from pathlib import Path +from re import error as RegexError from .cli import AbqpyCLI, abaqus from .run import run @@ -12,23 +13,15 @@ def _get_version(): - """Return the version string used for __version__.""" - # Only shell out to a git subprocess if really needed, and not on a - # shallow clone, such as those used by CI, as the latter would trigger - # a warning from setuptools_scm. root = Path(__file__).resolve().parents[2] if (root / ".git").exists() and not (root / ".git/shallow").exists(): try: import setuptools_scm - return setuptools_scm.get_version( - root=str(root), - version_scheme="guess-next-dev", - fallback_version=_default_version, - ) - except Exception: + return setuptools_scm.get_version(root=str(root)) + except (ImportError, RegexError, LookupError): return _default_version - else: # Get the version from the _version.py setuptools_scm file. + else: return _default_version @@ -39,4 +32,6 @@ def _get_version(): "run", "abaqus", "AbqpyCLI", + "__version__", + "__semver__", ]