Skip to content

Commit d4f5fd1

Browse files
committed
Transfer project metadata from setup.py to pyproject.toml
Notes: - setup.py is still needed for versioneer support. - versioneer.py vendoring is needed for Conda packaging (so that the version can be available to meta.yaml before the building itself). related_to #411
1 parent e4ebcdc commit d4f5fd1

File tree

9 files changed

+1051
-465
lines changed

9 files changed

+1051
-465
lines changed

.github/workflows/pip.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,14 @@ jobs:
4545
# This is needed so that the Git tag is parsed and the version is retrieved
4646
git config --global --add safe.directory $(realpath .)
4747
48+
# Upgrade Pip
49+
pip install --upgrade pip
50+
51+
# Install required Python build dependency
52+
pip install build
53+
4854
# Build the package
49-
python3 setup.py sdist
55+
python3 -m build --sdist
5056
- name: Upload package as artifact
5157
uses: actions/upload-artifact@v4
5258
with:
@@ -82,7 +88,9 @@ jobs:
8288
with:
8389
name: pip-package
8490
- name: Install package
85-
run: pip install $(ls khiops*.tar.gz)
91+
run: |
92+
pip install --upgrade pip
93+
pip install $(ls khiops*.tar.gz)
8694
- name: Run tests
8795
env:
8896
KHIOPS_SAMPLES_DIR: ${{ github.workspace }}/khiops-samples

.github/workflows/tests.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,13 @@ jobs:
105105
do
106106
# Since Python 3.13, setuptools is not installed automatically anymore
107107
$CONDA install -y -n "$CONDA_ENV" setuptools
108-
$CONDA run --no-capture-output -n "$CONDA_ENV" python setup.py egg_info
109-
$CONDA install -y -n "$CONDA_ENV" `grep -v "^\[" khiops.egg-info/requires.txt`
110-
rm -rf khiops.egg-info
108+
109+
# Add homogeneous TOML support (Python >= 3.12 has standard tomllib)
110+
$CONDA install -y -n "$CONDA_ENV" tomli
111+
$CONDA run --no-capture-output -n "$CONDA_ENV" python -c \
112+
"import tomli; from functools import reduce; fp = open('pyproject.toml', 'rb'); p = tomli.load(fp); fp.close(); print(' '.join(reduce(lambda x, y: x + y, list(p['project']['optional-dependencies'].values()), p['project']['dependencies'])))" > requires.txt
113+
$CONDA install -y -n "$CONDA_ENV" `cat requires.txt`
114+
rm -f requires.txt
111115
done
112116
- name: Configure Expensive Tests Setting
113117
# Skip expensive tests by default, unless on the `dev`, `dev-v10` or `main` branches
@@ -252,23 +256,22 @@ jobs:
252256
id: setup-python
253257
uses: actions/setup-python@v5
254258
with:
255-
python-version: '3.11'
259+
python-version: '3.12'
256260
- name: Install khiops-python dev dependencies
257261
shell: pwsh
258262
run: |
259263
# The following git command is required,
260264
# as the Git repository is in a directory the current user does not own,
261265
# Python versioneer fails to compute the current version correctly otherwise
262266
git config --global --add safe.directory $(Resolve-Path '.' | % {$_.toString()})
263-
python setup.py egg_info
267+
python -m pip install setuptools
268+
python -c `
269+
"import tomllib; from functools import reduce; fp = open('pyproject.toml', 'rb'); p = tomllib.load(fp); fp.close(); print('\n'.join(reduce(lambda x, y: x + y, list(p['project']['optional-dependencies'].values()), p['project']['dependencies'])))" > requires.txt
264270
265271
# Install the Python requirements
266-
Get-Content .\khiops.egg-info\requires.txt `
267-
| Select-String -Pattern '^\[' -NotMatch `
268-
| Select-String -Pattern '^$' -NotMatch `
269-
| % {$_.Line} `
272+
Get-Content .\requires.txt `
270273
| ForEach-Object {python -m pip install $_.toString()}
271-
Remove-Item -r -force khiops.egg-info
274+
Remove-Item -force requires.txt
272275
- name: Setup and Install Test Requirements
273276
run: python -m pip install -r test-requirements.txt
274277
- name: Test Khiops Integration
@@ -344,9 +347,12 @@ jobs:
344347
# as the Git repository is in a directory the current user does not own,
345348
# Python versioneer fails to compute the current version correctly otherwise
346349
git config --global --add safe.directory $(realpath .)
347-
python setup.py egg_info
348-
pip install `grep -v "^\[" khiops.egg-info/requires.txt`
349-
rm -rf khiops.egg-info
350+
# Install tomli for Python < 3.11
351+
pip install tomli
352+
python -c \
353+
"import tomli; from functools import reduce; fp = open('pyproject.toml', 'rb'); p = tomli.load(fp); fp.close(); print(' '.join(reduce(lambda x, y: x + y, list(p['project']['optional-dependencies'].values()), p['project']['dependencies'])))" > requires.txt
354+
pip install `cat requires.txt`
355+
rm -f requires.txt
350356
- name: Setup and Install Test Requirements
351357
run: |
352358
pip install -r test-requirements.txt

MANIFEST.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
recursive-exclude cicd *
21
recursive-exclude tests *
32
recursive-exclude doc *
43
exclude .git*
54
exclude CONTRIBUTING.md
65
exclude MANIFEST.in
7-
exclude pyproject.toml
8-
exclude sonar-project.properties
96
exclude test-requirements.txt
107
include khiops/samples/*.ipynb
11-
include khiops/_version.py
128
include khiops/core/scenarios/**/*._kh*
13-
include versioneer.py

0 commit comments

Comments
 (0)