Skip to content

Commit d578542

Browse files
committed
Specify the version on the Python side and on the Conda side
1 parent 576f3e9 commit d578542

File tree

4 files changed

+21
-27
lines changed

4 files changed

+21
-27
lines changed

.github/workflows/conda.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,21 @@ jobs:
111111
fi
112112
conda install ${RC_LABEL}khiops-core=$KHIOPS_CORE_VERSION
113113
conda install --channel ./khiops-conda/ khiops
114+
- name: Install JQ test dependency (Linux / MacOS)
115+
if: runner.os != 'Windows'
116+
run: conda install jq
117+
- name: Test Conda / Python Package Version Coherence
118+
run: |
119+
PACKAGE_VERSION=$(python -c "import khiops; print(khiops.__version__)")
120+
CONDA_VERSION=$(conda list ^khiops$ --json | jq ".[].version")
121+
122+
# Fail if CONDA_VERSION is not identical to $PACKAGE_VERSION
123+
echo $CONDA_VERSION | grep -wq $PACKAGE_VERSION
124+
if [[ $? -ne 0 ]]
125+
then
126+
echo "::error::Conda package version $CONDA_VERSION does not match Python package version $PYTHON_VERSION"
127+
false
128+
fi
114129
- name: Test Khiops Installation Status
115130
run: kh-status
116131
- name: Test Khiops Installation Status (Conda-Based Environments)

khiops/__init__.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,9 @@
2222
(extension ".khcj")
2323
- sklearn: Scikit-Learn estimator classes to learn and use Khiops models
2424
"""
25-
import importlib.metadata
26-
import os
27-
import sys
28-
import warnings
29-
from copy import copy
30-
from importlib.metadata import PackageNotFoundError
31-
from pathlib import Path
32-
3325
from khiops.core.internals.version import KhiopsVersion
3426

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("-", "")
27+
__version__ = "11.0.0.0b.0"
5128

5229

5330
def get_compatible_khiops_version():

packaging/conda/meta.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{% set name = load_file_data('../../pyproject.toml', from_recipe_dir=True).get('project').get('name') %}
2-
{% set version = load_file_data('../../pyproject.toml', from_recipe_dir=True).get('project').get('version') %}
32
package:
43
name: {{ name }}
54
# The Conda version cannot contain the '-' character, so we eliminate it
6-
version: {{ version | replace('-', '') }}
5+
version: "11.0.0.0b.0"
76

87
source:
98
path: ../../

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ ignore_errors = true
145145

146146
[project]
147147
name = "khiops"
148-
version = "11.0.0.0-b.0"
148+
dynamic = ["version"]
149149
description = "Python library for the Khiops AutoML suite"
150150
readme = "README.md"
151151
license = "BSD-3-Clause-Clear"
@@ -191,6 +191,9 @@ gcs = [
191191
include = ["khiops", "khiops.*"]
192192
namespaces = false
193193

194+
[tool.setuptools.dynamic]
195+
version = {attr = "khiops.__version__"}
196+
194197
[project.scripts]
195198
kh-status = "khiops.tools:kh_status_entry_point"
196199
kh-samples = "khiops.tools:kh_samples_entry_point"

0 commit comments

Comments
 (0)