Skip to content

Commit

Permalink
[bugfix] Update version configurations (#5771)
Browse files Browse the repository at this point in the history
  • Loading branch information
haiiliin authored Sep 3, 2024
1 parent 4bf6d41 commit 773f027
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "2024.0.0-dev"

[tool.pytest.ini_options]
testpaths = ["src", "tests"]
Expand Down
17 changes: 6 additions & 11 deletions src/abqpy/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


Expand All @@ -39,4 +32,6 @@ def _get_version():
"run",
"abaqus",
"AbqpyCLI",
"__version__",
"__semver__",
]

0 comments on commit 773f027

Please sign in to comment.