Skip to content

Commit 83fffdc

Browse files
authored
Merge pull request #16 from KhiopsML/version
fix: bump version
2 parents e2f5418 + d228182 commit 83fffdc

3 files changed

Lines changed: 21 additions & 18 deletions

File tree

docs/conf.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,19 @@
99
import re
1010
import sys
1111
from pathlib import Path
12-
import tomllib
12+
from importlib import metadata
1313

1414
DOCS_DIR = Path(__file__).resolve().parent
1515
ROOT_DIR = DOCS_DIR.parent
1616

1717
sys.path.append(str(ROOT_DIR))
1818
sys.path.append(str(ROOT_DIR / "src"))
1919

20-
21-
def _read_release() -> str:
22-
pyproject_file = ROOT_DIR / "pyproject.toml"
23-
data = tomllib.loads(pyproject_file.read_text(encoding="utf-8"))
24-
25-
try:
26-
return data["project"]["version"]
27-
except KeyError as exc:
28-
raise RuntimeError(
29-
f"Could not determine khisto version from {pyproject_file}"
30-
) from exc
31-
3220
project = 'khisto-python'
3321
copyright = '2026, The Khiops Team'
3422
author = 'The Khiops Team'
35-
release = _read_release()
23+
# We want to make sure the docs are built on an installed package only
24+
release = metadata.version("khisto")
3625

3726
# -- General configuration ---------------------------------------------------
3827
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "khisto"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "Optimal histogram visualization using the Khiops algorithm"
55
readme = "README.md"
66
license = "BSD-3-Clause-Clear"
@@ -80,6 +80,7 @@ dev = [
8080
{include-group = "test"},
8181
{include-group = "lint"},
8282
{include-group = "docs"},
83+
"tomli>=2.0.0; python_version < '3.11'" # TODO : Remove on Python 3.10 EOL
8384
]
8485

8586
[build-system]

src/khisto/__init__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@
1010
logging.basicConfig(level=logging.INFO)
1111
logger = logging.getLogger(__name__)
1212

13-
ROOT_DIR = Path(os.path.dirname(os.path.abspath(__file__))).parent.absolute()
14-
13+
ROOT_DIR = Path(__file__).resolve().parent.parent
1514
KHISTO_BIN_DIR = os.environ.get("KHISTO_BIN_DIR", "khisto")
1615

17-
__version__ = version("khisto")
16+
if (ROOT_DIR / "pyproject.toml").exists():
17+
# Development mode: package not installed; pyproject.toml present
18+
# TODO : Remove on Python 3.10 EOL
19+
try:
20+
import tomllib as tomli
21+
except ModuleNotFoundError:
22+
import tomli
23+
24+
with open(ROOT_DIR / "pyproject.toml", "rt") as f:
25+
__version__ = tomli.load(f)["project"]["version"]
26+
else:
27+
# User mode: package installed; pyproject.toml not directly accessible
28+
from importlib.metadata import version # noqa: E402
29+
30+
__version__ = version("khisto")
1831

1932
from .array import histogram # noqa: E402
2033
from .core import HistogramResult # noqa: E402

0 commit comments

Comments
 (0)