Skip to content

Commit 4ebd656

Browse files
Merge branch 'unstable' into maintainance/license_transfer_MIT
2 parents b30e88d + ec68120 commit 4ebd656

File tree

8 files changed

+46
-35
lines changed

8 files changed

+46
-35
lines changed

docs/source/conf.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
# this addition provided direct abbreviated link to the modules in the model
1818
sys.path.insert(1, os.path.abspath('../../temoa/temoa_model'))
1919

20+
# Import version from source (after sys.path setup)
21+
from temoa.__about__ import __version__
2022

2123
# -- Project information from pyproject.toml ---------------------------------
2224

23-
# Read version and metadata from pyproject.toml for single source of truth
25+
# Read metadata from pyproject.toml
2426
pyproject_path = Path(__file__).parent.parent.parent / 'pyproject.toml'
2527
with open(pyproject_path) as f:
2628
pyproject_data = tomlkit.load(f)
@@ -32,12 +34,11 @@
3234
)
3335
copyright = f'2011-{time.strftime("%Y")}, NC State University'
3436

35-
# The short X.Y version
36-
version = cast('str', project_metadata['version']).rsplit('.', 1)[
37-
0
38-
] # '4.0.0a1.dev20251113' -> '4.0.0a1'
39-
# The full version, including alpha/beta/rc tags
40-
release = str(project_metadata['version'])
37+
38+
# The short version
39+
version = __version__.rsplit('.', 1)[0]
40+
# The full version
41+
release = __version__
4142

4243

4344
# -- General configuration ---------------------------------------------------

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "temoa"
3-
version = "4.0.0a1"
3+
dynamic = ["version"]
44
description = "Tools for Energy Model Optimization and Analysis"
55
readme = "README.md"
66
requires-python = ">=3.12"
@@ -78,6 +78,9 @@ include = [
7878
package-data = { "temoa" = ["db_schema/*.sql", "tutorial_assets/*", "py.typed"] }
7979

8080

81+
[tool.hatch.version]
82+
path = "temoa/__about__.py"
83+
8184
[tool.ruff]
8285
line-length = 100
8386
indent-width = 4

temoa/__about__.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import re
2+
3+
__version__ = '4.0.0a1.dev20251201'
4+
5+
# Parse the version string to get major and minor versions
6+
# We use a regex to be robust against versions like "4.1a1" or "4.0.0.dev1"
7+
_match = re.match(r'^(\d+)\.(\d+)', __version__)
8+
if not _match:
9+
raise ValueError(
10+
f"Could not parse major/minor version from '{__version__}'. "
11+
"Expected format 'X.Y...' where X and Y are integers."
12+
)
13+
14+
TEMOA_MAJOR = int(_match.group(1))
15+
TEMOA_MINOR = int(_match.group(2))
16+
17+
# === REQUIREMENTS ===
18+
# python versions are tested internally for greater than these values
19+
MIN_PYTHON_MAJOR = 3
20+
MIN_PYTHON_MINOR = 12
21+
22+
# db is tested for match on major and >= on minor
23+
DB_MAJOR_VERSION = 4
24+
MIN_DB_MINOR_VERSION = 0

temoa/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
# Core API - public interface
1010
# Internal modules - for backward compatibility
11+
# Version information
12+
from temoa.__about__ import TEMOA_MAJOR, TEMOA_MINOR, __version__
1113
from temoa._internal.data_brick import DataBrick, data_brick_factory
1214
from temoa._internal.exchange_tech_cost_ledger import CostType, ExchangeTechCostLedger
1315
from temoa._internal.run_actions import (
@@ -30,11 +32,6 @@
3032
from temoa.core.modes import TemoaMode
3133
from temoa.data_io.hybrid_loader import HybridLoader
3234

33-
# Version information
34-
from temoa.version_information import TEMOA_MAJOR, TEMOA_MINOR
35-
36-
__version__ = '4.0.0a1'
37-
3835
# Maintain backward compatibility for common imports
3936
__all__ = [
4037
# Core API

temoa/_internal/temoa_sequencer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
from logging import getLogger
1111
from typing import TYPE_CHECKING
1212

13+
from temoa.__about__ import (
14+
DB_MAJOR_VERSION,
15+
MIN_DB_MINOR_VERSION,
16+
MIN_PYTHON_MAJOR,
17+
MIN_PYTHON_MINOR,
18+
)
1319
from temoa._internal.run_actions import (
1420
build_instance,
1521
check_database_version,
@@ -28,12 +34,6 @@
2834
from temoa.extensions.myopic.myopic_sequencer import MyopicSequencer
2935
from temoa.extensions.single_vector_mga.sv_mga_sequencer import SvMgaSequencer
3036
from temoa.model_checking.pricing_check import price_checker
31-
from temoa.version_information import (
32-
DB_MAJOR_VERSION,
33-
MIN_DB_MINOR_VERSION,
34-
MIN_PYTHON_MAJOR,
35-
MIN_PYTHON_MINOR,
36-
)
3737

3838
if TYPE_CHECKING:
3939
import pyomo.opt

temoa/cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
from rich.logging import RichHandler
1313
from rich.text import Text
1414

15+
from temoa.__about__ import __version__
1516
from temoa._internal.temoa_sequencer import TemoaSequencer
1617
from temoa.core.config import TemoaConfig
1718
from temoa.core.modes import TemoaMode
1819
from temoa.utilities import db_migration_v3_1_to_v4, sql_migration_v3_1_to_v4
19-
from temoa.version_information import TEMOA_MAJOR, TEMOA_MINOR
2020

2121
# =============================================================================
2222
# Logging & Helper Setup
@@ -103,7 +103,7 @@ def _setup_sequencer(
103103
# =============================================================================
104104
def _version_callback(value: bool) -> None:
105105
if value:
106-
version = f'{TEMOA_MAJOR}.{TEMOA_MINOR}'
106+
version = __version__
107107
rich.print(f'Temoa Version: [bold green]{version}[/bold green]')
108108
raise typer.Exit()
109109

temoa/version_information.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)