Skip to content

Commit a327551

Browse files
committed
refactor: Dynamically retrieve package version via importlib.metadata and update version tests.
1 parent ee0b48c commit a327551

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "apcore-cli"
7-
version = "0.1.0"
7+
version = "0.2.0"
88
description = "Terminal adapter for apcore — execute AI-Perceivable modules from the command line"
99
readme = "README.md"
1010
license = "Apache-2.0"

src/apcore_cli/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
"""apcore-cli: CLI adapter for the apcore module ecosystem."""
22

3-
__version__ = "0.1.0"
3+
from importlib.metadata import PackageNotFoundError
4+
from importlib.metadata import version as _get_version
5+
6+
try:
7+
__version__ = _get_version("apcore-cli")
8+
except PackageNotFoundError:
9+
__version__ = "unknown"

tests/test_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,10 @@ def test_main_version_flag(self, tmp_path):
257257
runner = CliRunner()
258258
result = runner.invoke(create_cli(extensions_dir=str(tmp_path), prog_name="apcore-cli"), ["--version"])
259259
assert result.exit_code == 0
260+
from apcore_cli import __version__
261+
260262
assert "apcore-cli" in result.output
261-
assert "0.1.0" in result.output
263+
assert __version__ in result.output
262264

263265
def test_main_extensions_dir_not_found(self):
264266
import pytest

tests/test_e2e.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,5 +464,7 @@ def test_python_m_apcore_cli_version(self, tmp_path):
464464
text=True,
465465
timeout=10,
466466
)
467+
from apcore_cli import __version__
468+
467469
assert result.returncode == 0
468-
assert "0.1.0" in result.stdout
470+
assert __version__ in result.stdout

0 commit comments

Comments
 (0)