File tree Expand file tree Collapse file tree 8 files changed +46
-35
lines changed
Expand file tree Collapse file tree 8 files changed +46
-35
lines changed Original file line number Diff line number Diff line change 1717# this addition provided direct abbreviated link to the modules in the model
1818sys .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
2426pyproject_path = Path (__file__ ).parent .parent .parent / 'pyproject.toml'
2527with open (pyproject_path ) as f :
2628 pyproject_data = tomlkit .load (f )
3234)
3335copyright = 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 ---------------------------------------------------
Original file line number Diff line number Diff line change 11[project ]
22name = " temoa"
3- version = " 4.0.0a1 "
3+ dynamic = [ " version " ]
44description = " Tools for Energy Model Optimization and Analysis"
55readme = " README.md"
66requires-python = " >=3.12"
@@ -78,6 +78,9 @@ include = [
7878package-data = { "temoa" = [" db_schema/*.sql" , " tutorial_assets/*" , " py.typed" ] }
7979
8080
81+ [tool .hatch .version ]
82+ path = " temoa/__about__.py"
83+
8184[tool .ruff ]
8285line-length = 100
8386indent-width = 4
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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__
1113from temoa ._internal .data_brick import DataBrick , data_brick_factory
1214from temoa ._internal .exchange_tech_cost_ledger import CostType , ExchangeTechCostLedger
1315from temoa ._internal .run_actions import (
3032from temoa .core .modes import TemoaMode
3133from 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
Original file line number Diff line number Diff line change 1010from logging import getLogger
1111from 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+ )
1319from temoa ._internal .run_actions import (
1420 build_instance ,
1521 check_database_version ,
2834from temoa .extensions .myopic .myopic_sequencer import MyopicSequencer
2935from temoa .extensions .single_vector_mga .sv_mga_sequencer import SvMgaSequencer
3036from 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
3838if TYPE_CHECKING :
3939 import pyomo .opt
Original file line number Diff line number Diff line change 1212from rich .logging import RichHandler
1313from rich .text import Text
1414
15+ from temoa .__about__ import __version__
1516from temoa ._internal .temoa_sequencer import TemoaSequencer
1617from temoa .core .config import TemoaConfig
1718from temoa .core .modes import TemoaMode
1819from 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# =============================================================================
104104def _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
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments