Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix] Update version configurations (backport #5771) #5776

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "2019.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__",
]
Loading