Skip to content

Commit

Permalink
copy get_vcs_version function
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaspie committed Jul 4, 2024
1 parent 02f9faf commit 96f8e00
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
4 changes: 3 additions & 1 deletion _build_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]:
"--match",
tag_match,
],
cwd=os.path.join(os.path.dirname(__file__), "../pynxtools/definitions"),
cwd=os.path.join(
os.path.dirname(__file__), "src/pynxtools/definitions"
),
check=True,
capture_output=True,
)
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[build-system]
requires = ["setuptools>=64.0.1", "setuptools-scm[toml]>=6.2"]
backend-path = ["."]
build-backend = "_build_wrapper"

[project]
Expand Down
31 changes: 30 additions & 1 deletion src/pynxtools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,42 @@
import os
import re
from datetime import datetime
from subprocess import CalledProcessError, run
from typing import Optional

from pynxtools._build_wrapper import get_vcs_version
from pynxtools.definitions.dev_tools.globals.nxdl import get_nxdl_version

MAIN_BRANCH_NAME = "fairmat"


def get_vcs_version(tag_match="*[0-9]*") -> Optional[str]:
"""
The version of the Nexus standard and the NeXus Definition language
based on git tags and commits
"""
try:
return (
run(
[
"git",
"describe",
"--dirty",
"--tags",
"--long",
"--match",
tag_match,
],
cwd=os.path.join(os.path.dirname(__file__), "../pynxtools/definitions"),
check=True,
capture_output=True,
)
.stdout.decode("utf-8")
.strip()
)
except (FileNotFoundError, CalledProcessError):
return None


def _build_version(tag: str, distance: int, node: str, dirty: bool) -> str:
"""
Builds the version string for a given set of git states.
Expand Down

0 comments on commit 96f8e00

Please sign in to comment.