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
Cython source file is not compiled after pixi install/update #1695
The project contains some cython code, which should be compiled when installing the default environment. The compiled file should be in the folder called build. There are some founding about the folder build
when .pixi/envs/ does not contain default environment, pixi install will correctly generate build folder.
when .pixi/envs/ contains default environment but build folder for some reason is missing, pixi install will not generate build folder and only print "The default environment has been installed."
In the previous version of pixi (I can't remember the exact version number), pixi update will solve the problem 2, but the latest version 0.26.1 cannot anymore.
When I use prefix-dev/[email protected] for github CI (cache enable), build folder is missing and cannot be regenerate by pixi update.
Expected behavior
When I run pixi install or pixi update, pixi should check whether the environment properly install the project (in editable mode) which contain cython code. If the build folder missing, pixi should notice it and regenerate it.
Hi! I think this is because uv became a bit smarter with just building the metadata of wheels, during the solve. The workaround for now is to use pixi clean && pixi install. I do not know a really good way of fixing this yet, as we cannot really detect that it this has happened. Only by adding an exception(s) for different build-backends.
Something we could relatively easily implement is pixi install --force or something of the sort, that forces a re-install of enveryting (or maybe a specifiable packages), would this help at all?
If editable = false, the cython source code will not be compiled. In other words, the command pip install . will install a python module without compiling cython source code. As far as I know, the common practice is to compile cython code inplace, either using python setup.py build_ext --inplace see ref or python -m pip install --no-build-isolation --editable . see ref.
How do you expect an editable cython package to behave? Should that rebuild on install or what does it mean?
As here says: "Please note that some kind of changes, such as the addition or modification of entry points or the addition of new dependencies, and generally all changes involving package metadata, require a new installation step to become effective."
I think whenever cython source code change or package metadata change, the package should be reinstalled.
Something we could relatively easily implement is pixi install --force or something of the sort, that forces a re-install of enveryting (or maybe a specifiable packages), would this help at all?
I think it may not be plausible to reinstall the entire env whenever the cython code is changed. Because during the development, the cython code is changed very often. It will be helpful to provide cli to reinstall the local package only.
Another thing is about using prefix-dev/[email protected] GitHub Action. I think the local package should be automatically reinstalled even when caching is enabled.
We're currently always "checking" if the environment is up-to-date when you run pixi run/shell/install/etc. which would make a reinstall on all of those an unusable experience.
Would it make sense to have some special behavior for pixi install when using path dependencies? E.g. always reinstalling even if the cache is still valid. I'm not a fan of differences in behavior, but it might feel familiar for most people. But "familiar for most" is always a bad assumption so not sure what the best way forward would be.
Plus to solve the action cache problem, also rebuild on a clean prefix installation to skip the cache here.
Plus to solve the action cache problem, also rebuild on a clean prefix installation to skip the cache here.
It will solve the problem to simply set cache=false, but the whole env will be reinstalled. The way I can find to reinstall the local package only is to run
pixi run "uv pip install --no-deps --force-reinstall -e ."
However, pixi seems not to pre-install any installer, such as pip and uv, so I have to install uv first via
curl -LsSf https://astral.sh/uv/install.sh | sh
Should pixi also support flags, such as --no-deps and --force-reinstall to make reinstall local package easier?
I think all of these settings could make sense for pixi.
--no-deps: For this we fist have to modify pixi install to install only a given package.
--force-reinstall: This should not be to hard as we should just skip the cache.
We deliberatly don't install any other package managers as there should in theory be no reason to need extra installers. For these more demanding projects you can also install uv with pixi add uv for now.
--no-deps would still hit the cache though, I think, so would not re-install. The problem is that a frontend only needs to rebuild if the metadata could be changed, as we do not really know what the backend does, we cant be sure.
The quote:
"Please note that some kind of changes, such as the addition or modification of entry points or the addition of new dependencies, and generally all changes involving package metadata, require a new installation step to become effective."
So I think most of the times the C/C++ code does not change the metadata, so there is no need for a frontend to rebuild.
However, I think, we could think of a combination of flags that would work :)
With some more testing, I'm now kind of rethinking the whole thing. I've tried doing an install with uv and while it does not seem to build the code, it is actually bringing back the build folder. But that build folder, is not contained in the wheel as expected. So it makes me wonder where that is cached.
We should have a closer look at what's happening here. @olivier-lacroix do you have any experience with mesonpy in this regard?
Sorry I'm thinking out loud here in this issue. But it works for uv if I add an empty dynamic = [] to the pyproject.toml. However, that does not work, for us that is a bug 🐛 and we should fix it. Let me make an issue later.
uv also does not seem to rebuild when dynamic is added and build folder is deleted. They do have a --reinstall-package that seems to work. It's still pretty slow.
@MatthewSZhang it would be great that if you could check if you like the flags for uv i.e. fit your workflow and behaves as you would expect, if you have the time of course. You can successfully install your repo with uv in an activated pixi shell.
e.g
# install uv, through github, homebrew, pip (pixi global install does not work as of now)
uv venv .venv
uv pip install -e .
Hi @tdejager , I have tried uv pip install -e .. And after I delete build folder, uv pip install --no-deps --force-reinstall -e . will recompile my cython code to .so file (.pyd for windows), and put it to build folder in a reasonable speed. So I think if pixi supports flags --no-deps and --force-reinstall will be helpful. -e may be unnecessary, as we define whether a package is editable in the pyproject.toml such as
So the resulting cli is something like pixi update --no-deps --force-reinstall mypk I suppose?
There are two things that may need to be clarified:
If using uv pip install --force-reinstall -e ., that will be slow, as all the dependencies will be re-installed as well. See here says --force-reinstall:
Reinstall package(s), and their dependencies, even if they are already up-to-date.
Therefore, --no-deps is necessary.
If mypk is written in pure python and installed in editable mode, it is not necessary to reinstall it when only .py source code changes. So it is expected that uv pip install -e . will not reinstall the local package when package meta does not change.
However, if mypk contains .pyx cython code, even package meta data does not change, the mypk need to be re-installed whenever .pyx file changes. Because the mypk need to the compiled .so (.pyd for windows) file to work properly.
Of course, .pyx file can be compiled manually using such as meson setup .. and meson compile .. or python setup.py build_ext --inplace for setuptools. But I have to set the build directory manually (such as build/cp312) to match the configuration used by the installer like pip or uv (also pixi). So reinstalling mypk via installers is better than compiling it manually to me.
Just chiming in on the possible API for this, as I had similar thoughts for docker layering purposes in #1652 (comment)
I don’t feel like a —no-deps would be very suitable for pixi install, which deals with the entire environment. I feel like having flags to exclude / only deal with path dependencies, like poetry does, and as @ruben-arts suggested above is a more natural fit.
This being said, there may be some value in having a separate pixi command (e.g. pixi force-install ?) to deal with a single / select package(s)
I’m encountering a similar issue. I’m working on a C++ and Python project using scikit-build-core as the build backend. When I make changes to the C++ source code, running pixi install doesn’t recompile the .so files. I’ve tried running pixi run "uv pip install --no-deps --force-reinstall -e ." as well as pixi clean && pixi install, but neither approach works. Previously, using pip install -e . would rebuild the entire package as expected.
The only way I’ve found to get pixi to reinstall my package is by toggling the editable flag in pyproject.toml between true and false.
I’m encountering a similar issue. I’m working on a C++ and Python project using scikit-build-core as the build backend. When I make changes to the C++ source code, running pixi install doesn’t recompile the .so files. I’ve tried running pixi run "uv pip install --no-deps --force-reinstall -e ." as well as pixi clean && pixi install, but neither approach works. Previously, using pip install -e . would rebuild the entire package as expected.
The only way I’ve found to get pixi to reinstall my package is by toggling the editable flag in pyproject.toml between true and false.
I think it should be --reinstall for uv and not --force-reinstall. In any case, I plan on working on PR next week to be able to re-install and refresh (which should trigger rebuilds) PyPI packages.
Reacted by rlchen, Koyo MUNECHIKA, Sikai Zhang and Julian Rüth
Do you have any updates? I would greatly appreciate it if you could manage this, as it would free me from the tedious routines of pixi clean and pixi install for Cython code development.
--reinstall-package <pkg-name> to re-install a specific package.
--reinstall to re-install everything.
Re-installing implies a refresh for the dependencies managed by uv, and that could be something we could add for conda later as well. Refresh meaning the refreshing of the cached metadata.
Re-installing also implies the rebuilding of both the conda and PyPI source packages.
Options to specifically refresh but not per se re-install for conda based source and binary packages is something that we can add CLI flags for at a later stage as well.
I noticed that even writing and redoing something in pyproject.toml causes the package to rebuild during pixi install. It seems that pixi checks its hash value, and its change triggers a rebuild.
Activity
ruben-arts commentedon Jul 30, 2024
Does the issue persist for
editable = false?How do you expect an editable cython package to behave? Should that rebuild on install or what does it mean?
tdejager commentedon Jul 30, 2024
Hi! I think this is because uv became a bit smarter with just building the metadata of wheels, during the solve. The workaround for now is to use
pixi clean && pixi install. I do not know a really good way of fixing this yet, as we cannot really detect that it this has happened. Only by adding an exception(s) for different build-backends.Something we could relatively easily implement is
pixi install --forceor something of the sort, that forces a re-install of enveryting (or maybe a specifiable packages), would this help at all?MatthewSZhang commentedon Jul 31, 2024
If
editable = false, the cython source code will not be compiled. In other words, the commandpip install .will install a python module without compiling cython source code. As far as I know, the common practice is to compile cython codeinplace, either usingpython setup.py build_ext --inplacesee ref orpython -m pip install --no-build-isolation --editable .see ref.As here says: "Please note that some kind of changes, such as the addition or modification of entry points or the addition of new dependencies, and generally all changes involving package metadata, require a new installation step to become effective."
I think whenever cython source code change or package metadata change, the package should be reinstalled.
I think it may not be plausible to reinstall the entire env whenever the cython code is changed. Because during the development, the cython code is changed very often. It will be helpful to provide cli to reinstall the local package only.
Another thing is about using
prefix-dev/[email protected]GitHub Action. I think the local package should be automatically reinstalled even when caching is enabled.ruben-arts commentedon Jul 31, 2024
We're currently always "checking" if the environment is up-to-date when you run
pixi run/shell/install/etc.which would make a reinstall on all of those an unusable experience.Would it make sense to have some special behavior for
pixi installwhen usingpathdependencies? E.g. always reinstalling even if the cache is still valid. I'm not a fan of differences in behavior, but it might feel familiar for most people. But "familiar for most" is always a bad assumption so not sure what the best way forward would be.Plus to solve the action cache problem, also rebuild on a clean
prefixinstallation to skip the cache here.MatthewSZhang commentedon Aug 1, 2024
It will solve the problem to simply set
cache=false, but the whole env will be reinstalled. The way I can find to reinstall the local package only is to runpixi run "uv pip install --no-deps --force-reinstall -e ."However,
pixiseems not to pre-install any installer, such as pip and uv, so I have to installuvfirst viacurl -LsSf https://astral.sh/uv/install.sh | shShould
pixialso support flags, such as--no-depsand--force-reinstallto make reinstall local package easier?ruben-arts commentedon Aug 1, 2024
I think all of these settings could make sense for pixi.
--no-deps: For this we fist have to modifypixi installto install only a given package.--force-reinstall: This should not be to hard as we should just skip the cache.We deliberatly don't install any other package managers as there should in theory be no reason to need extra installers. For these more demanding projects you can also install
uvwithpixi add uvfor now.tdejager commentedon Aug 1, 2024
--no-depswould still hit the cache though, I think, so would not re-install. The problem is that a frontend only needs to rebuild if the metadata could be changed, as we do not really know what the backend does, we cant be sure.The quote:
So I think most of the times the C/C++ code does not change the metadata, so there is no need for a frontend to rebuild.
However, I think, we could think of a combination of flags that would work :)
tdejager commentedon Aug 1, 2024
With some more testing, I'm now kind of rethinking the whole thing. I've tried doing an
installwith uv and while it does not seem to build the code, it is actually bringing back thebuildfolder. But thatbuildfolder, is not contained in the wheel as expected. So it makes me wonder where that is cached.We should have a closer look at what's happening here. @olivier-lacroix do you have any experience with
mesonpyin this regard?olivier-lacroix commentedon Aug 1, 2024
None whatsoever @tdejager :-/
tdejager commentedon Aug 1, 2024
Again, now that I'm thinking of it, it might be meson doing it itself.
tdejager commentedon Aug 1, 2024
Sorry I'm thinking out loud here in this issue. But it works for uv if I add an emptydynamic = []to thepyproject.toml. However, that does not work, for us that is a bug 🐛 and we should fix it. Let me make an issue later.uvalso does not seem to rebuild whendynamicis added and build folder is deleted. They do have a--reinstall-packagethat seems to work. It's still pretty slow.@MatthewSZhang it would be great that if you could check if you like the flags for uv i.e. fit your workflow and behaves as you would expect, if you have the time of course. You can successfully install your repo with uv in an activated pixi shell.
e.g
And then do the modifcations as you see fit.
MatthewSZhang commentedon Aug 2, 2024
Hi @tdejager , I have tried
uv pip install -e .. And after I deletebuildfolder,uv pip install --no-deps --force-reinstall -e .will recompile my cython code to .so file (.pyd for windows), and put it tobuildfolder in a reasonable speed. So I think ifpixisupports flags--no-depsand--force-reinstallwill be helpful.-emay be unnecessary, as we define whether a package is editable in thepyproject.tomlsuch asSo the resulting cli is something like
pixi update --no-deps --force-reinstall mypkI suppose?There are two things that may need to be clarified:
uv pip install --force-reinstall -e ., that will be slow, as all the dependencies will be re-installed as well. See here says--force-reinstall:mypkis written in pure python and installed in editable mode, it is not necessary to reinstall it when only .py source code changes. So it is expected thatuv pip install -e .will not reinstall the local package when package meta does not change.However, if
mypkcontains .pyx cython code, even package meta data does not change, themypkneed to be re-installed whenever .pyx file changes. Because themypkneed to the compiled.so(.pydfor windows) file to work properly.Of course,
.pyxfile can be compiled manually using such asmeson setup ..andmeson compile ..orpython setup.py build_ext --inplaceforsetuptools. But I have to set the build directory manually (such as build/cp312) to match the configuration used by the installer likepiporuv(alsopixi). So reinstallingmypkvia installers is better than compiling it manually to me.olivier-lacroix commentedon Aug 2, 2024
Just chiming in on the possible API for this, as I had similar thoughts for docker layering purposes in #1652 (comment)
I don’t feel like a
—no-depswould be very suitable forpixi install, which deals with the entire environment. I feel like having flags to exclude / only deal with path dependencies, like poetry does, and as @ruben-arts suggested above is a more natural fit.This being said, there may be some value in having a separate pixi command (e.g.
pixi force-install?) to deal with a single / select package(s)7 remaining items
MatthewSZhang commentedon Aug 8, 2024
Hi @rgommers Thanks for your explanation and I understand meson better now :)
Hi @tdejager
The build dir will loss when using github action
prefix-dev/[email protected]and setcache: true. It seemspixiwill not cache build dir.r1cheu commentedon Oct 5, 2024
I’m encountering a similar issue. I’m working on a C++ and Python project using scikit-build-core as the build backend. When I make changes to the C++ source code, running pixi install doesn’t recompile the .so files. I’ve tried running
pixi run "uv pip install --no-deps --force-reinstall -e ."as well aspixi clean && pixi install, but neither approach works. Previously, usingpip install -e .would rebuild the entire package as expected.The only way I’ve found to get pixi to reinstall my package is by toggling the editable flag in pyproject.toml between true and false.
tdejager commentedon Oct 5, 2024
I think it should be
--reinstallfor uv and not--force-reinstall. In any case, I plan on working on PR next week to be able to re-install and refresh (which should trigger rebuilds) PyPI packages.munechika-koyo commentedon Jan 10, 2025
Seems like
--reinstallhas already been implemented at uv pip install.Can Pixi handle this functionality?
tdejager commentedon Jan 10, 2025
Yeah you are right, we should start including this!
munechika-koyo commentedon Feb 13, 2025
Do you have any updates? I would greatly appreciate it if you could manage this, as it would free me from the tedious routines of
pixi cleanandpixi installfor Cython code development.tdejager commentedon Feb 13, 2025
Make sense, I'll update the issue once I know. Sorry for the delays!
tdejager commentedon Feb 27, 2025
So what I'm thinking:
--reinstall-package <pkg-name>to re-install a specific package.--reinstallto re-install everything.Re-installing implies a refresh for the dependencies managed by uv, and that could be something we could add for conda later as well. Refresh meaning the refreshing of the cached metadata.
Re-installing also implies the rebuilding of both the conda and PyPI source packages.
Options to specifically
refreshbut not per sere-installfor conda based source and binary packages is something that we can add CLI flags for at a later stage as well.tdejager commentedon Mar 10, 2025
This is my plan for implementation:
pyrattlerbindings as well.tdejager commentedon Mar 10, 2025
Sketch of functionality:
munechika-koyo commentedon Mar 11, 2025
Hofer-Julian commentedon Mar 11, 2025
Yes, that is an unrelated issue @munechika-koyo
feat: add `pixi reinstall`