Skip to content
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
3 changes: 2 additions & 1 deletion python/.env.versions
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
HATCH_VERSION="1.14.2"

# Full pip install command
HATCH_INSTALL_CMD="pip install hatch==${HATCH_VERSION}"
# Pin virtualenv<21 to work around https://github.com/pypa/hatch/issues/2193
HATCH_INSTALL_CMD="pip install hatch==${HATCH_VERSION} virtualenv<21"
1 change: 1 addition & 0 deletions python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extra-dependencies = [
[tool.hatch.envs.lint]
path = ".venv/lint"
template = "testenv"
skip-install = true
dependencies = [
"flake8",
"black==24.4.1"
Expand Down
22 changes: 2 additions & 20 deletions python/version.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
import subprocess

CURRENT_VERSION = "0.1.30"
# run a shell command and return stdout
def run_cmd(cmd):
cmd_proc = subprocess.run(cmd, shell=True, capture_output=True)
if cmd_proc.returncode != 0:
raise OSError(
f"Shell command '{cmd}' failed with return code {cmd_proc.returncode}\n"
f"STDERR: {cmd_proc.stderr.decode('utf-8')}"
)
return cmd_proc.stdout.decode("utf-8").strip()


# fetch the most recent build version for hatch environment creation
def get_version():
"""Return the package version based on latest git tag."""
"""Return the package version based on CURRENT_VERSION or env override."""
import os

# Optionally override with environment variable
if "PACKAGE_VERSION" in os.environ:
return os.environ.get("PACKAGE_VERSION")

# Fall back to git tag
try:
return CURRENT_VERSION
except (OSError, ValueError) as E:
# Return a fallback version if git operations fail
# TODO - Raise with error message
raise E
return CURRENT_VERSION


__version__ = get_version()