On Monday, 8 September 2025 at 08:35:49 UTC+2 tobia...@gmx.de wrote:
Thanks for bringing this up! > what will be the recommended way to depend on sagemath in a pip package As with any other python dependency: If you compile against sage (eg using cython), you should specify `sagemath` under `build-system > requires` in the pyproject.toml of your project. If sage is just a runtime dependency, then put it under `project > dependencies`. Thanks. So slightly related to this. Does this mean that `sage -pip install sagemath==10.7` is going to be a supported way to update sagemath? I created a sample project having sagemath>=10.7 as a dependency. And doing `sage -pip install .` using sage 10.6 actually seems to have upgraded sage from 10.6 to 10.7. However doing the same for sage 10.5 or earlier seems to fail. In any case when starting to use sagemath more as a proper python dependency things like this will happen. > how to tell end users to install my pip package in an already working sage installation Ideally, it would be like any other pip package: tell users to activate the venv they want to install it in, then run `pip install <your pip package>`. However, if you have sagemath declared as build requirement, then this might build sage again (if there is no cached wheel) since pip creates a new empty build env by default. To prevent that, one should use `pip install --no-build-isolation <your pip package>` in the sage venv. We should add some documentation for downstream sagemath packages. Yes I would love this. There used to be sage_sample for this: https://github.com/sagemath/sage_sample but that is horribly outdated as there is no pyproject.toml, and uses travis_ci . On Sunday, September 7, 2025 at 9:34:53 AM UTC+8 m.derick...@gmail.com wrote: Hi, I maintain a pip installable python package that depends on sagemath. And installing this package in sage using sage -pip install git+https://github.com/koffie/mdsage.git recently broke. When I looked at why it broke I was happily surprised because it seems that sagemath is now finally uploading packages to pypi. The reason this breaks is because I was relying on the behavior of the old "fake" sagemath pypi package that essentially was just a package that only checked if the sage library was available in that python environment. But now it seems that sagemath really is finally starting to behave like a proper python library. My question is, going forward what will be the recommended way to depend on sagemath in a pip package, and how to tell end users to install my pip package in an already working sage installation? At the moment I fixed the problems by pinning the sagemath python package version to 1.3.0 . But I am sure that this is not the proper way forward. See below for what goes wrong in sagemath 10.3 and 10.5 ~$ sage -pip install git+https://github.com/koffie/mdsage.git@devel Defaulting to user installation because normal site-packages is not writeable Collecting git+https://github.com/koffie/mdsage.git@devel Cloning https://github.com/koffie/mdsage.git (to revision devel) to /tmp/pip-req-build-h6_c3fau Running command git clone --filter=blob:none --quiet https://github.com/koffie/mdsage.git /tmp/pip-req-build-h6_c3fau Running command git checkout -b devel --track origin/devel Switched to a new branch 'devel' Branch 'devel' set up to track remote branch 'devel' from 'origin'. Resolved https://github.com/koffie/mdsage.git to commit ebe7afdf1fcfec8d8737a7a51a02b2a638aa2f74 Preparing metadata (setup.py) ... done Collecting sagemath>=10.7.0 (from mdsage==0.1.0) Using cached sagemath-10.7.tar.gz (30.9 MB) Installing build dependencies ... The log goes on for quite a bit. But as you can imagine it should already be clear at this point that it will fail, since installing sage 10.7 in the python environment of an older sage version doesn't sound like a good idea. Thanks, Maarten -- You received this message because you are subscribed to the Google Groups "sage-devel" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/sage-devel/c0a281eb-a269-4842-a591-27c9ff79e3e0n%40googlegroups.com.