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`. > 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. 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/0c816c04-879d-4386-8b70-2b586f9946b0n%40googlegroups.com.