rebuilding Cython files in `conda` installation

70 views
Skip to first unread message

Gareth Ma

unread,
Jan 24, 2024, 11:22:21 AM1/24/24
to sage-devel
Hi all, my development Sage installation uses the conda instructions here. There is a command below for how to recompile Cython files:

pip install --no-build-isolation --config-settings editable_mode=compat -v -v --editable src

However, it seems that it recompiles every Cython file, even the ones I haven't touched. This happens everytime, not just the first time I run the command. Is that normal? Is it possible to only recompile files I have changed?

I tried running cythonize -i a.pyx directly on the file. However, it seems to break something and some libraries are not loaded correctly. For example, I was editing sage/rings/finite_rings/element_pari_ffelt.pyx, and after running the cythonize command Sage complains that the ConwayDatabase is missing.

(I hope I am not posting in the wrong mailing group)

Dima Pasechnik

unread,
Jan 24, 2024, 11:37:58 AM1/24/24
to sage-...@googlegroups.com


On 24 January 2024 15:58:56 GMT, Gareth Ma <grh...@gmail.com> wrote:
>Hi all, my development Sage installation uses the conda instructions here
><https://doc.sagemath.org/html/en/installation/conda.html#using-conda-to-provide-all-dependencies-for-the-sage-library>.
>There is a command below for how to recompile Cython files:
>
>pip install --no-build-isolation --config-settings editable_mode=compat -v
>-v --editable src
>
>However, it seems that it recompiles *every* Cython file, even the ones I
>haven't touched. This happens everytime, not just the first time I run the
>command. Is that normal?

yes, this is normal if you use pip this way.
If you went for a more regular Sage installation where you can run make, then such rebuilds would have been much faster, as there is dependency tracking then.

Nils Bruin

unread,
Jan 24, 2024, 12:12:40 PM1/24/24
to sage-devel
On Wednesday 24 January 2024 at 08:22:21 UTC-8 Gareth Ma wrote:
Hi all, my development Sage installation uses the conda instructions here. There is a command below for how to recompile Cython files:

pip install --no-build-isolation --config-settings editable_mode=compat -v -v --editable src

I think with these options, you'd end up with the installed files living right in src. Once they're there you can use whatever procedure to rebuild them. It may well be that a "make build" with the right environment set up does the right thing in the sage library. At that point, "src" could even be a git repo. I'm not so sure if dependency/change tracking will still work across package boundaries, but getting proper incremental rebuilding for sagelib should be attainable (and quite frankly required for a conda/pip install to be a viable way for sage development)

I've certainly used "pip --editable" installs for smaller python/cython packages and was able to incrementally rebuild on them. The "pip" part is to get the files in place and linked up with a python environment. After that you're down to the build/make tools coming with the package.

Gareth Ma

unread,
Jan 24, 2024, 2:34:54 PM1/24/24
to sage-...@googlegroups.com
Thank you both for the suggestion, I went with Dima's suggestion by running `sage -b` once, and now it supports incremental building. I will try Nils' approach and see if I can figure it out - if I do, I will add it to the conda-forge installation documentations page :)

Best regards,
Gareth
Reply all
Reply to author
Forward
0 new messages