File tree Expand file tree Collapse file tree 6 files changed +22
-3088
lines changed
Expand file tree Collapse file tree 6 files changed +22
-3088
lines changed Original file line number Diff line number Diff line change 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
2726import os
2827import sys
2928import warnings
3029from copy import copy
30+ from importlib .metadata import PackageNotFoundError
3131from pathlib import Path
3232
33- from khiops ._version import get_versions
3433from 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
4053def get_compatible_khiops_version ():
You can’t perform that action at this time.
0 commit comments