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 . metadata import version
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+ release = version ( "khisto" )
3624
3725# -- General configuration ---------------------------------------------------
3826# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Original file line number Diff line number Diff line change @@ -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+ # TODO : Remove on Python 3.10 EOL
18+ try :
19+ import tomllib as tomli
20+ except ModuleNotFoundError :
21+ import tomli
22+
23+ with open (ROOT_DIR / "pyproject.toml" , "rt" ) as f :
24+ __version__ = tomli .load (f )["project" ]["version" ]
25+ else :
26+ from importlib .metadata import version # noqa: E402
27+
28+ __version__ = version ("khisto" )
1829
1930from .array import histogram # noqa: E402
2031from .core import HistogramResult # noqa: E402
You can’t perform that action at this time.
0 commit comments