From 59689911b2ba614ff0e61e661edddd5be68f13d0 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Fri, 19 Jun 2026 17:14:30 +0200 Subject: [PATCH 1/5] fix: bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index fdb47a1..ad160b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "khisto" -version = "0.2.0" +version = "0.3.0" description = "Optimal histogram visualization using the Khiops algorithm" readme = "README.md" license = "BSD-3-Clause-Clear" From 620aa6fd1fed6306e607a07d6ca28adf307c089a Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Fri, 19 Jun 2026 18:23:53 +0200 Subject: [PATCH 2/5] fix: make the version attr of the package available without install --- docs/conf.py | 16 ++-------------- pyproject.toml | 1 + src/khisto/__init__.py | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 2c8928e..acd2c43 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ import re import sys from pathlib import Path -import tomllib +from importlib.metadata import version DOCS_DIR = Path(__file__).resolve().parent ROOT_DIR = DOCS_DIR.parent @@ -17,22 +17,10 @@ sys.path.append(str(ROOT_DIR)) sys.path.append(str(ROOT_DIR / "src")) - -def _read_release() -> str: - pyproject_file = ROOT_DIR / "pyproject.toml" - data = tomllib.loads(pyproject_file.read_text(encoding="utf-8")) - - try: - return data["project"]["version"] - except KeyError as exc: - raise RuntimeError( - f"Could not determine khisto version from {pyproject_file}" - ) from exc - project = 'khisto-python' copyright = '2026, The Khiops Team' author = 'The Khiops Team' -release = _read_release() +release = version("khisto") # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index ad160b4..61b6f48 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -80,6 +80,7 @@ dev = [ {include-group = "test"}, {include-group = "lint"}, {include-group = "docs"}, + "tomli>=2.0.0; python_version < '3.11'" # TODO : Remove on Python 3.10 EOL ] [build-system] diff --git a/src/khisto/__init__.py b/src/khisto/__init__.py index ed8f3ad..a5dfe57 100644 --- a/src/khisto/__init__.py +++ b/src/khisto/__init__.py @@ -10,11 +10,22 @@ logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) -ROOT_DIR = Path(os.path.dirname(os.path.abspath(__file__))).parent.absolute() - +ROOT_DIR = Path(__file__).resolve().parent.parent KHISTO_BIN_DIR = os.environ.get("KHISTO_BIN_DIR", "khisto") -__version__ = version("khisto") +if (ROOT_DIR / "pyproject.toml").exists(): + # TODO : Remove on Python 3.10 EOL + try: + import tomllib as tomli + except ModuleNotFoundError: + import tomli + + with open(ROOT_DIR / "pyproject.toml", "rt") as f: + __version__ = tomli.load(f)["project"]["version"] +else: + from importlib.metadata import version # noqa: E402 + + __version__ = version("khisto") from .array import histogram # noqa: E402 from .core import HistogramResult # noqa: E402 From acc36f87fb42b26a500c610161a8c249dc951726 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Fri, 19 Jun 2026 18:31:45 +0200 Subject: [PATCH 3/5] fix: solve name conflict in doc conf on version var --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index acd2c43..c535613 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ import re import sys from pathlib import Path -from importlib.metadata import version +import importlib DOCS_DIR = Path(__file__).resolve().parent ROOT_DIR = DOCS_DIR.parent @@ -20,7 +20,7 @@ project = 'khisto-python' copyright = '2026, The Khiops Team' author = 'The Khiops Team' -release = version("khisto") +release = importlib.metadata.version("khisto") # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration From ee7990e3a04295c34bb7d94faff059e3e557ebc0 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Fri, 19 Jun 2026 18:36:11 +0200 Subject: [PATCH 4/5] fix: add comments --- docs/conf.py | 1 + src/khisto/__init__.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index c535613..007ded2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,6 +20,7 @@ project = 'khisto-python' copyright = '2026, The Khiops Team' author = 'The Khiops Team' +# We want to make sure the docs are built on an installed package only release = importlib.metadata.version("khisto") # -- General configuration --------------------------------------------------- diff --git a/src/khisto/__init__.py b/src/khisto/__init__.py index a5dfe57..5fd5450 100644 --- a/src/khisto/__init__.py +++ b/src/khisto/__init__.py @@ -14,6 +14,7 @@ KHISTO_BIN_DIR = os.environ.get("KHISTO_BIN_DIR", "khisto") if (ROOT_DIR / "pyproject.toml").exists(): + # Development mode: package not installed; pyproject.toml present # TODO : Remove on Python 3.10 EOL try: import tomllib as tomli @@ -23,6 +24,7 @@ with open(ROOT_DIR / "pyproject.toml", "rt") as f: __version__ = tomli.load(f)["project"]["version"] else: + # User mode: package installed; pyproject.toml not directly accessible from importlib.metadata import version # noqa: E402 __version__ = version("khisto") From d228182dfc81a9e6422e040021e07cf993850ce8 Mon Sep 17 00:00:00 2001 From: Elouen Ginat Date: Mon, 22 Jun 2026 09:13:31 +0200 Subject: [PATCH 5/5] fix: dolve import issue in conf doc --- docs/conf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 007ded2..81de350 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -9,7 +9,7 @@ import re import sys from pathlib import Path -import importlib +from importlib import metadata DOCS_DIR = Path(__file__).resolve().parent ROOT_DIR = DOCS_DIR.parent @@ -21,7 +21,7 @@ copyright = '2026, The Khiops Team' author = 'The Khiops Team' # We want to make sure the docs are built on an installed package only -release = importlib.metadata.version("khisto") +release = metadata.version("khisto") # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration