You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow automatically reinstalling path-based PyPI packages when files change #3985
When using pixi to manage the build environment for a pypi package, it is useful to be able to automatically reinstall the package into its own environment whenever source files are updated.
This isn't as important for pure-python packages, which can get by using editable = true, but this isn't sufficient for packages that need complex build steps, like those involving extension modules.
A simple way to solve this problem would be to add a property to pypi packages specifying a list of files to watch for changes, similar to task inputs and uv's cache-keys.
In this example, if any changes were detected in src/*.cpp, the package would be treated as outdated and be reinstalled automatically whenever the environment is checked (eg. before a pixi run or pixi shell command), as if you had run pixi reinstall my-test-package
It is possible to approximate this behaviour today, using a task:
it must be specified explicitly as a dependency of every other task, and doesn't work correctly for things like pixi shell or pixi run python.
in the event of modifications to the pixi.toml, it will rebuild the environment twice - once prior to running the build task, and once when the build task is run.
Another approach is to use activation hooks, however:
this requires writing a separate script, since pixi can't run tasks from activation hooks
this requires writing caching behaviour manually, for the same reason. it's not possible to simply write a script that runs pixi run build, because that recurses infinitely and there doesn't seem to be a way to temporarily disable activation hooks
as with the task-based workaround above, this approach can result in rebuilding the package multiple times
[tasks]
test = { cmd = "pytest", depends-on = ["setup-install"] }
setup-install.cmd = "uv pip install --no-build-isolation -C editable.rebuild=true -C build-dir=build -e ."setup-install.inputs = ["pyproject.toml"] # Just need something in here so it caches; scikit-build-core will handle the actual caching
It's similar to the task-based approach using pixi rebuild above, but it uses uv (pip would work fine too) to build and install the package manually, rather than relying on pixi to do so.
This only works because of scikit-build-core's automatic rebuild feature, which is still experimental. It'd still be nice to properly support this sort of thing in pixi natively.
This is a feature we are aiming for with pixi build, however, we could think of something for PyPI at some point as well. The focus would be the pixi build use-case first though :)
Activity
silversquirl commentedon Jun 20, 2025
I've come up with this workaround for now:
It's similar to the task-based approach using
pixi rebuildabove, but it usesuv(pipwould work fine too) to build and install the package manually, rather than relying on pixi to do so.This only works because of scikit-build-core's automatic rebuild feature, which is still experimental. It'd still be nice to properly support this sort of thing in pixi natively.
lucascolley commentedon Jun 21, 2025
relevant discussion in the particular case of meson-python and uv at astral-sh/uv#10214 and mesonbuild/meson-python#730
tdejager commentedon Jul 8, 2025
This is a feature we are aiming for with
pixi build, however, we could think of something for PyPI at some point as well. The focus would be the pixi build use-case first though :)cpcloud commentedon Sep 15, 2025
I would love to see this. I just hit this issue going between branches with different Cython code and was very surprised to see no rebuild happen.