Skip to content

Commit c088226

Browse files
pjhartzellircwaves
authored andcommitted
review: pull version into __init__ and readthedocs conf.py
1 parent 8664802 commit c088226

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

docs/source/conf.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@
22

33
import os
44
import sys
5+
import subprocess
6+
from datetime import datetime
57

68
sys.path.insert(0, os.path.abspath("../..")) # Source code dir relative to this file
79

810
# -- Project information
911

1012
project = "STAC Task"
11-
copyright = "2025, Element 84, Inc."
13+
copyright = f"{datetime.now().year}, Element 84, Inc."
1214

13-
release = "0.6.1"
14-
version = "0.6.1"
15+
16+
def get_latest_tag() -> str:
17+
try:
18+
result = subprocess.run(
19+
["git", "describe", "--tags", "--abbrev=0"],
20+
capture_output=True,
21+
text=True,
22+
check=True,
23+
)
24+
return result.stdout.strip()
25+
except:
26+
return "0.0.0"
27+
28+
29+
release = get_latest_tag()
30+
version = release
1531

1632
# -- General configuration
1733

stactask/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
from contextlib import suppress
2-
from importlib.metadata import PackageNotFoundError, version
3-
4-
with suppress(PackageNotFoundError):
5-
__version__ = version("stactask")
6-
71
from .config import DownloadConfig
82
from .payload import Payload
93
from .task import Task
104

11-
__all__ = ["Task", "Payload", "DownloadConfig"]
5+
try:
6+
from .__version__ import __version__, __version_tuple__
7+
except ImportError:
8+
__version__ = "0.0.0"
9+
__version_tuple__ = ("0", "0", "0")
10+
11+
__all__ = [
12+
"__version__",
13+
"__version_tuple__",
14+
"Task",
15+
"Payload",
16+
"DownloadConfig",
17+
]

0 commit comments

Comments
 (0)