Skip to content

Commit b66b78c

Browse files
committed
Drop versioneer; hard-code the version, as for the Khiops binaries
1 parent e6b11ab commit b66b78c

File tree

6 files changed

+22
-3088
lines changed

6 files changed

+22
-3088
lines changed

khiops/__init__.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,32 @@
2222
(extension ".khcj")
2323
- sklearn: Scikit-Learn estimator classes to learn and use Khiops models
2424
"""
25-
import importlib
26-
import importlib.util
25+
import importlib.metadata
2726
import os
2827
import sys
2928
import warnings
3029
from copy import copy
30+
from importlib.metadata import PackageNotFoundError
3131
from pathlib import Path
3232

33-
from khiops._version import get_versions
3433
from khiops.core.internals.version import KhiopsVersion
3534

36-
__version__ = get_versions()["version"]
37-
del get_versions
35+
try:
36+
# Package is installed
37+
__version__ = importlib.metadata.version(__name__)
38+
except PackageNotFoundError:
39+
# Package is not installed, hence parse the pyproject.toml file
40+
try:
41+
# Python >= 3.11: use the standard-library tomllib module
42+
import tomllib as tomli
43+
except ModuleNotFoundError:
44+
# Python < 3.11: use the Pip-vendored tomli module
45+
from pip._vendor import tomli
46+
with open("pyproject.toml", "rb") as metadata_file:
47+
metadata = tomli.load(metadata_file)
48+
49+
# Strip "-" from pre-release versions to match installed package metadata
50+
__version__ = metadata.get("project").get("version").replace("-", "")
3851

3952

4053
def get_compatible_khiops_version():

0 commit comments

Comments
 (0)