Skip to content

feat: Add Pixi workspace to pyproject.toml - #2638

Merged
matthewfeickert merged 15 commits into
scikit-hep:mainfrom
matthewfeickert:feat/add-pixi-workspace-config
Jan 5, 2026
Merged

feat: Add Pixi workspace to pyproject.toml#2638
matthewfeickert merged 15 commits into
scikit-hep:mainfrom
matthewfeickert:feat/add-pixi-workspace-config

Conversation

@matthewfeickert

@matthewfeickert matthewfeickert commented Nov 20, 2025

Copy link
Copy Markdown
Member

Description

  • Add Pixi workspace to pyproject.toml under [tool.pixi] table.
    • Add environments for all extras and dependency-groups.
    • Add Pixi tasks for all sessions in Nox.
    • Create conda specific environments so the only Python package is pyhf.
  • Add Pixi lock file to .gitignore.
  • Add .pixi/config to allow for insecure run-post-link-scripts.
  • Add sphinx-autobuild as 'dev' dependency group requirement.
    • 'dev' is chosen over 'docs' as 'docs' should include only the required
      dependencies to build and deploy the docs to the website.

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* Add Pixi workspace to pyproject.toml under [tool.pixi] table.
   - Add environments for all extras and dependency-groups.
   - Add Pixi tasks for all sessions in Nox.
   - Create conda specific environments so the only Python package is pyhf.
* Add Pixi lock file to .gitignore.
* Add .pixi/config to allow for insecure run-post-link-scripts.
* Add sphinx-autobuild as 'dev' dependency group requirement.
   - 'dev' is chosen over 'docs' as 'docs' should include only the required
      dependencies to build and deploy the docs to the website.

@matthewfeickert matthewfeickert self-assigned this Nov 20, 2025
@matthewfeickert matthewfeickert added the feat/enhancement New feature or request label Nov 20, 2025
@github-project-automation github-project-automation Bot moved this to In progress in pyhf v0.8.0 Nov 20, 2025
@codecov

codecov Bot commented Nov 20, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (be966d4) to head (86791fd).
⚠️ Report is 24 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2638   +/-   ##
=======================================
  Coverage   98.24%   98.24%           
=======================================
  Files          65       65           
  Lines        4220     4220           
  Branches      464      464           
=======================================
  Hits         4146     4146           
  Misses         45       45           
  Partials       29       29           
Flag Coverage Δ
contrib 98.12% <ø> (ø)
doctest 98.24% <ø> (ø)
unittests-3.10 96.44% <ø> (ø)
unittests-3.11 96.44% <ø> (ø)
unittests-3.12 96.44% <ø> (ø)
unittests-3.13 96.44% <ø> (ø)
unittests-3.9 96.49% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matthewfeickert

matthewfeickert commented Nov 20, 2025

Copy link
Copy Markdown
Member Author

I've been making heavy use of https://pixi.sh/latest/python/pyproject_toml/#optional-dependencies for this PR and for testing.

I'm also realizing from this PR (/ remembering Issue #2622) that click-completion is in maintenance mode

shellcomplete = ["click_completion"]

and that there is a native Click v8 completion. c.f. https://click.palletsprojects.com/en/stable/shell-completion/#shell-completion

@matthewfeickert matthewfeickert left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This adds a fully conda-package-based Pixi workspace for pyhf, such that the only Python package is pyhf itself:

$ pixi list -e dev | grep pypi
Environment: dev
pyhf                              0.7.1.dev336                                     pypi

It adds a suite of Pixi tasks as well

$ pixi task list
Tasks that can run on this machine:
-----------------------------------
benchmarks, build-docs, build-package, doctest, lint, notebooks, serve, test, test-contrib
Task           Description
benchmarks     Run the benchmarks
build-docs     Build the pyhf documentation website
build-package  Build a sdist and wheel
doctest        Run the doctest tests
lint           Run pre-commit
notebooks      Run the test suite for the notebooks
serve          Serve the docs website
test           Run the test suite on the core library
test-contrib   Run the test suite for the contrib module

and the ability to get a CUDA accelerated jaxlib environment

$ pixi list -e jax-gpu jax
Environment: jax-gpu
Name    Version  Build                            Size  Kind   Source
jax     0.7.2    pyhd8ed1ab_0                 1.78 MiB  conda  https://conda.anaconda.org/conda-forge
jaxlib  0.7.2    cuda129_py313h33cbcf4_202  166.01 MiB  conda  https://conda.anaconda.org/conda-forge
$ pixi run -e jax-gpu python
Python 3.13.11 | packaged by conda-forge | (main, Dec  6 2025, 11:24:03) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
>>> import pyhf
>>> jax.devices()
[CudaDevice(id=0)]

When Pixi is solving it will raise the following warnings

WARN The package `pytest-benchmark==5.2.3` does not have an extra named `histogram`
WARN The package `coverage==7.13.0` does not have an extra named `toml`
WARN The package `pytest-benchmark==5.2.3` does not have an extra named `histogram`
WARN The package `coverage==7.13.0` does not have an extra named `toml`

which can't be avoided as far as I know, given that it is trying to resolve the extras that exist in the test dependency-group

"coverage[toml]>=6.0.0",

"pytest-benchmark[histogram]",

and can't.

Comment thread pyproject.toml
Comment on lines +403 to +404
pixi exec python-build --installer uv . && \
pixi exec twine check --strict ./dist/*

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Doing pixi exec here are these are transitory processes that don't need to have their dependencies constrain the rest of the dev environment.

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.

Why not use package functionalities here with the pixi-build preview?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is that faster or more convenient? That seems like more configuration for no clear benefit.

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.

I've found it to be a little faster in pyhs3.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Given that for this PR I wanted to get things working and in a single file, and scipp-atlas/pyhs3#145 has shown us that for now we would need to also use pixi.toml I'd prefer to skip this till pixi-build is fully out of preview.

Comment thread pyproject.toml
default = { solve-group = "default" }
jax = { features = ["jax"], solve-group = "default" }
jax-cpu = { features = ["jax-cpu"], solve-group = "default" }
jax-gpu = { features = ["jax-gpu"], solve-group = "gpu" }

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Add jax-gpu environment so can get a CUDA enabled jaxlib on demand.

@matthewfeickert
matthewfeickert marked this pull request as ready for review December 18, 2025 23:42
@matthewfeickert

Copy link
Copy Markdown
Member Author

cc @MoAly98 @ikrommyd given discussion on scikit-hep/coffea#1503

@matthewfeickert

Copy link
Copy Markdown
Member Author

Note that as you can't specify default environments for tasks yet (c.f. prefix-dev/pixi#5140) when you run

pixi run test

you'll be asked to select an environment

$ pixi run test
? The task 'test' can be run in multiple environments.

Please select an environment to run the task in: ›test
  dev

Currently the only way to avoid this is to specify the environment at runtime

pixi run --environment test test

.

@matthewfeickert
matthewfeickert force-pushed the feat/add-pixi-workspace-config branch from a5155b3 to 2885793 Compare December 26, 2025 19:19
@matthewfeickert

Copy link
Copy Markdown
Member Author

cc @kratsg for review.

Comment thread pyproject.toml
rsync -r ./src/pyhf/schemas ./docs/_build/html/
"""

[tool.pixi.feature.docs.tasks.serve]

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.

I would also add a [...tasks.watch] that does sphinx-autobuild --open-browser -n -T -b html docs docs/_build/html which autoreloads when changes are made.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done, but in dev environment.

Comment thread pyproject.toml
Comment on lines +403 to +404
pixi exec python-build --installer uv . && \
pixi exec twine check --strict ./dist/*

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.

Why not use package functionalities here with the pixi-build preview?

Comment thread pyproject.toml
@github-project-automation github-project-automation Bot moved this from In progress to Review in progress in pyhf v0.8.0 Dec 27, 2025
@kratsg

kratsg commented Dec 27, 2025

Copy link
Copy Markdown
Contributor

Note that as you can't specify default environments for tasks yet (c.f. prefix-dev/pixi#5140) when you run

Technically, you can do this by simply keeping the task to a single environment. There's some clever restructuring one can do if you don't need all envs all at once.

@matthewfeickert
matthewfeickert requested a review from kratsg January 5, 2026 18:08
@matthewfeickert

Copy link
Copy Markdown
Member Author

Technically, you can do this by simply keeping the task to a single environment. There's some clever restructuring one can do if you don't need all envs all at once.

@kratsg indeed. We probably can try to do extra clever things moving forward, but I might suggest that we postpone until we can reevaluate the pixi-build backends.

@matthewfeickert
matthewfeickert merged commit b191d3d into scikit-hep:main Jan 5, 2026
22 checks passed
@matthewfeickert
matthewfeickert deleted the feat/add-pixi-workspace-config branch January 5, 2026 18:39
@github-project-automation github-project-automation Bot moved this from Review in progress to Done in pyhf v0.8.0 Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat/enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants