Skip to content

MAINT Switch the CI to pixi - #34212

Draft
glemaitre wants to merge 6 commits into
scikit-learn:mainfrom
glemaitre:pixi_setup
Draft

glemaitre wants to merge 6 commits into
scikit-learn:mainfrom
glemaitre:pixi_setup

Conversation

@glemaitre

@glemaitre glemaitre commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Testing what it costs to switch to pixi for the CI environment.

@glemaitre
glemaitre marked this pull request as draft June 8, 2026 13:39
@ogrisel

ogrisel commented Jun 15, 2026 •

Copy link
Copy Markdown
Member

Thanks for drafting this PR @glemaitre. After IRL discussion, it seems that there is no configuration option in pyproject.toml to tell pixi to keep lockfile frozen until being explicitly asked to refresh them. The alternative would be to always pass --frozen to most common lines or ask users to configure the PIXI_FROZEN=true env var which is tedious and confusing: I would much prefer have the frozen behavior configured by default for all contributors and CI runners in pyproject.toml and then let the weekly lockfile refresher bot open PRs to test that it's safe to bump the version numbers in all the managed dependencies without breaking the CI.

EDIT: the default pixi behavior has changed since last time I checked. Maybe this configuration option is not needed anymore.

@adrinjalali

Copy link
Copy Markdown
Member

given prefix-dev/pixi#2628 (comment) I think we can go ahead with this PR.

@ogrisel ogrisel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is some more feedback.

Once this PR is finalized, I would rather wait a week before merging it and push a commit that only refreshes the pixi lock file to be able to visualize the typical weekly diff we will have to review later and compare to what we currently deal with using conda-lock.

name: Build wheel for Pull Request
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? It seems unrelated to the scope of the PR. We could consider this change in the context of #34006 but I would rather not mix this with the change to pixi if not needed.

run-install: false

- name: Update pixi lock file
run: pixi update

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want a single PR to update all the lock files at once? I think prefer distinct PRs for jobs with more experimental or more complex sets of dependencies and that are as a result likely to fail more often such as CUDA CI, free-threaded and scipy-dev.

Separate PRs allow for more focused investigative discussion threads in my opinion.

On the other hand, having many PRs, requires a bit more manual actions to approve and merge them all when everything goes well (which is 50% of the time or more in my experience). And it's also true that sometimes the failures and their resolution are somewhat correlated between lockfile update PRs.

So I am ok with either approach.

# environments are actually exercised on the PR. scipy-dev is not
# included on purpose: it does not use pixi and installs the latest
# development dependencies at run time, independently of the lock file.
commit-message: "Update CI pixi lock file [free-threaded] [doc build]"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about [scipy-dev]?

Comment thread pyproject.toml
[tool.pixi.environments]
dev = { features = ["tests", "docs", "dev"] }
mkl = { features = ["mkl"], no-default-feature = true }
osx-arm64 = { features = ["osx-arm64"], no-default-feature = true }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather stop using "osx" in build config names we control. Let's instead use "macos". The OSX naming was abandoned by Apple several years ago in favor of macOS.

# The ubuntu_atlas and debian_32bit builds do not use a conda/pixi
# environment: they install numpy/scipy with apt and the remaining
# dependencies from a pip lock file. These two lock files are still maintained
# with the legacy `update_environments_and_lock_files.py` script.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it possible to also manage this via pixi? I thought pixi could be configured to set up environments with wheel packages from the PyPI distribution channel with the help of uv.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

echo "Installing numpy, scipy and pandas nightly wheels"
dev_anaconda_url=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
dev_packages="numpy scipy pandas"
pip install --pre --upgrade --timeout=60 --extra-index $dev_anaconda_url $dev_packages --only-binary :all:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot this configuration of the nightly build distribution channel be also moved to a dedicated pixi feature in pyproject.toml?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably

Comment thread pyproject.toml
# environment, exactly like the previous conda-lock based setup.
[tool.pixi.workspace]
channels = ["conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64", "win-64"]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also configure a default exclude-newer policy (for instance "7d") to make our CI more resilient against OSS Supply Chain attacks:

https://pixi.prefix.dev/dev/security/#2-delay-fresh-uploads-with-exclude-newer

uses: prefix-dev/setup-pixi@5185adfbffb4bd703da3010310260805d89ebb11 # v0.9.6
with:
pixi-version: ${{ env.PIXI_VERSION }}
manifest-path: pyproject.toml

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needed?

pixi-version: ${{ env.PIXI_VERSION }}
manifest-path: pyproject.toml
environments: cuda
locked: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +61 to +64
# Make the cuda environment available on the PATH of the following
# steps so that `python`/`pytest` resolve to it without `pixi run`.
# This also lets us run from outside the checkout directory.
activate-environment: cuda

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another option is to make all of the following available as Pixi tasks, but this is fine 👍

Comment thread pyproject.toml
# environment, exactly like the previous conda-lock based setup.
[tool.pixi.workspace]
channels = ["conda-forge"]
platforms = ["linux-64", "linux-aarch64", "osx-64", "osx-arm64", "win-64"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread pyproject.toml
Comment on lines +515 to +516
[tool.pixi.feature.cuda.system-requirements]
cuda = "12"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

Comment thread pyproject.toml
Comment on lines +500 to +506
# NOTE: the scipy-dev build (numpy/scipy/pandas nightly wheels + git-master
# Cython/joblib/Pillow) is intentionally NOT managed by pixi. Those development
# versions change every day, while pixi.lock is only refreshed weekly, so
# pinning them would mean testing stale "dev" versions and churning the lock.
# That build installs its dependencies at run time instead; see the `scipy-dev`
# job in .github/workflows/unit-tests.yml and the `scipy-dev` branch in
# build_tools/github/install.sh.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for SciPy I think we are considering setting up a separate repository or fork to run such CI on

Comment thread pyproject.toml
# feature implicitly. The remaining environments are one per CI build and set
# ``no-default-feature`` so the default dependencies stay out of them.
# ----------------------------------------------------------------------------
[tool.pixi.environments]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably easier to make the 'default' environment its own environment and then not need to specify no-default-feature everywhere.

echo "Installing numpy, scipy and pandas nightly wheels"
dev_anaconda_url=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
dev_packages="numpy scipy pandas"
pip install --pre --upgrade --timeout=60 --extra-index $dev_anaconda_url $dev_packages --only-binary :all:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably

# The ubuntu_atlas and debian_32bit builds do not use a conda/pixi
# environment: they install numpy/scipy with apt and the remaining
# dependencies from a pip lock file. These two lock files are still maintained
# with the legacy `update_environments_and_lock_files.py` script.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants