Skip to content

Migrate to pyproject toml #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
default: main
description: khiops-python-tutorial repo revision
image-tag:
default: 10.7.3-a.0.0
default: 10.7.3-a.0.1
description: Development Docker Image Tag
pull_request:
paths:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
# because the `env` context is only accessible at the step level;
# hence, it is hard-coded
image: |-
ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || '10.7.3-a.0.0' }}
ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || '10.7.3-a.0.1' }}
# Use the 'runner' user (1001) from github so checkout actions work properly
# https://github.com/actions/runner/issues/2033#issuecomment-1598547465
options: --user 1001
Expand All @@ -67,14 +67,19 @@ jobs:
run: echo PATH="$PATH:/github/home/.local/bin" >> "$GITHUB_ENV"
- name: Install doc build requirements
run: |
pip install setuptools --upgrade

# Install tomli so that pyproject.toml can be parsed
pip install tomli

# Install package itself to install the samples datasets
pip3 install .
pip install .
kh-download-datasets --force-overwrite
kh-status

# Install the doc python requirements
cd doc
pip3 install -U -r requirements.txt
pip install -U -r requirements.txt
- name: Build Sphinx Documentation
run: |
cd doc
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
default: 11.0.0
description: khiops-samples repo revision
image-tag:
default: 10.7.3-a.0.0
default: 10.7.3-a.0.1
description: Development Docker Image Tag
pull_request:
paths:
Expand Down Expand Up @@ -45,8 +45,14 @@ jobs:
# This is needed so that the Git tag is parsed and the version is retrieved
git config --global --add safe.directory $(realpath .)

# Upgrade Pip
pip install --upgrade pip

# Install required Python build dependency
pip install build

# Build the package
python3 setup.py sdist
python3 -m build --sdist
- name: Upload package as artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -64,7 +70,7 @@ jobs:
# because the `env` context is only accessible at the step level;
# hence, it is hard-coded
image: |-
ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '10.7.3-a.0.0' }}
ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '10.7.3-a.0.1' }}
steps:
- name: Set parameters as env
run: |
Expand All @@ -82,7 +88,9 @@ jobs:
with:
name: pip-package
- name: Install package
run: pip install $(ls khiops*.tar.gz)
run: |
pip install --upgrade pip
pip install $(ls khiops*.tar.gz)
- name: Run tests
env:
KHIOPS_SAMPLES_DIR: ${{ github.workspace }}/khiops-samples
Expand Down
38 changes: 22 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
default: 11.0.0
description: Git Tag/Branch/Commit for the khiops-samples Repo
image-tag:
default: 10.7.3-a.0.0
default: 10.7.3-a.0.1
description: Development Docker Image Tag
khiops-desktop-revision:
default: 10.7.3-a.0
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
# because the `env` context is only accessible at the step level;
# hence, it is hard-coded
image: |-
ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || '10.7.3-a.0.0' }}
ghcr.io/khiopsml/khiops-python/khiopspydev-ubuntu22.04:${{ inputs.image-tag || '10.7.3-a.0.1' }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -105,9 +105,13 @@ jobs:
do
# Since Python 3.13, setuptools is not installed automatically anymore
$CONDA install -y -n "$CONDA_ENV" setuptools
$CONDA run --no-capture-output -n "$CONDA_ENV" python setup.py egg_info
$CONDA install -y -n "$CONDA_ENV" `grep -v "^\[" khiops.egg-info/requires.txt`
rm -rf khiops.egg-info

# Add homogeneous TOML support (Python >= 3.12 has standard tomllib)
$CONDA install -y -n "$CONDA_ENV" tomli
$CONDA run --no-capture-output -n "$CONDA_ENV" python -c \
"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
$CONDA install -y -n "$CONDA_ENV" `cat requires.txt`
rm -f requires.txt
done
- name: Configure Expensive Tests Setting
# Skip expensive tests by default, unless on the `dev`, `dev-v10` or `main` branches
Expand Down Expand Up @@ -252,23 +256,22 @@ jobs:
id: setup-python
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Install khiops-python dev dependencies
shell: pwsh
run: |
# The following git command is required,
# as the Git repository is in a directory the current user does not own,
# Python versioneer fails to compute the current version correctly otherwise
git config --global --add safe.directory $(Resolve-Path '.' | % {$_.toString()})
python setup.py egg_info
python -m pip install setuptools
python -c `
"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

# Install the Python requirements
Get-Content .\khiops.egg-info\requires.txt `
| Select-String -Pattern '^\[' -NotMatch `
| Select-String -Pattern '^$' -NotMatch `
| % {$_.Line} `
Get-Content .\requires.txt `
| ForEach-Object {python -m pip install $_.toString()}
Remove-Item -r -force khiops.egg-info
Remove-Item -force requires.txt
- name: Setup and Install Test Requirements
run: python -m pip install -r test-requirements.txt
- name: Test Khiops Integration
Expand Down Expand Up @@ -315,7 +318,7 @@ jobs:
# because the `env` context is only accessible at the step level;
# hence, it is hard-coded
image: |-
ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '10.7.3-a.0.0' }}
ghcr.io/khiopsml/khiops-python/khiopspydev-${{ matrix.container }}:${{ inputs.image-tag || '10.7.3-a.0.1' }}
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -344,9 +347,12 @@ jobs:
# as the Git repository is in a directory the current user does not own,
# Python versioneer fails to compute the current version correctly otherwise
git config --global --add safe.directory $(realpath .)
python setup.py egg_info
pip install `grep -v "^\[" khiops.egg-info/requires.txt`
rm -rf khiops.egg-info
# Install tomli for Python < 3.11
pip install tomli
python -c \
"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
pip install `cat requires.txt`
rm -f requires.txt
- name: Setup and Install Test Requirements
run: |
pip install -r test-requirements.txt
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ recursive-exclude doc *
exclude .git*
exclude CONTRIBUTING.md
exclude MANIFEST.in
exclude pyproject.toml
exclude sonar-project.properties
exclude test-requirements.txt
include khiops/samples/*.ipynb
include khiops/_version.py
include khiops/core/scenarios/**/*._kh*
include versioneer.py
Loading
Loading