-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make VRS schema release info accessible in VRS-Python
- Loading branch information
1 parent
7c5629e
commit 412012d
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from setuptools import setup | ||
from pathlib import Path | ||
import subprocess | ||
|
||
|
||
class VrsSubmoduleFetchError(Exception): | ||
"""Raise for errors during submodule metadata extraction""" | ||
|
||
|
||
def get_vrs_submodule_info(): | ||
"""Retrieve the commit hash and tag from the vrs submodule.""" | ||
try: | ||
try: | ||
tag = subprocess.check_output( | ||
["git", "describe", "--tags", "--abbrev=0"], cwd="submodules/vrs", text=True | ||
).strip() | ||
except subprocess.CalledProcessError: | ||
raise VrsSubmoduleFetchError | ||
return tag | ||
except Exception as e: | ||
raise VrsSubmoduleFetchError from e | ||
|
||
|
||
def write_metadata_file(): | ||
"""Generate a Python module with submodule metadata.""" | ||
tag = get_vrs_submodule_info() | ||
metadata_path = Path("src/ga4gh/vrs/submodule_metadata.py") | ||
metadata_path.parent.mkdir(parents=True, exist_ok=True) | ||
metadata_path.write_text( | ||
f"# Auto-generated metadata from VRS schema submodule\n" | ||
f"VRS_RELEASE = '{tag}'\n" | ||
) | ||
|
||
|
||
write_metadata_file() | ||
|
||
# Use setuptools for the actual build (delegates to pyproject.toml) | ||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto-generated metadata for VRS submodule | ||
VRS_TAG = '2.0.0.connect.2024-04.1' |