File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import re
1010import sys
1111from pathlib import Path
12- import tomllib
12+ from importlib import metadata
1313
1414DOCS_DIR = Path (__file__ ).resolve ().parent
1515ROOT_DIR = DOCS_DIR .parent
1616
1717sys .path .append (str (ROOT_DIR ))
1818sys .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-
3220project = 'khisto-python'
3321copyright = '2026, The Khiops Team'
3422author = '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
Original file line number Diff line number Diff line change 11[project ]
22name = " khisto"
3- version = " 0.2 .0"
3+ version = " 0.3 .0"
44description = " Optimal histogram visualization using the Khiops algorithm"
55readme = " README.md"
66license = " 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 ]
Original file line number Diff line number Diff line change 1010logging .basicConfig (level = logging .INFO )
1111logger = 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
1514KHISTO_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
1932from .array import histogram # noqa: E402
2033from .core import HistogramResult # noqa: E402
You can’t perform that action at this time.
0 commit comments