Hi Dima, First of all thanks for your quick response. Yes I agree that I need to update the way my package is build and installed most of the code in setup.py is over 8 years old. In fact that is why I started this question here, because I am unsure what are the best ways to do it.
Also one addition is that I would like to state is. I would very much like to depend on a "recent enough sage version" in such a way that installing inside a to old sage version raises some form of error telling them to update sage. I relied on "sagemath.check_version" to do this. At the moment I feel that maybe inlining the code in 'sagemath.check_version" in my install script might be the best way forward. I guess I could not do this check any rely more on the existing python infrastructure, and letting go of the idea of "a sagemath installation", and start to think more as sagemath the python library. But I don't really like the user experience of getting an error message that sagemath==10.7 failed to install inside an existing sage 10.5 installation. Note that my package doesn't break the latest stable release (10.7) , this doesn't mean that I claim what the package does right now should still be supported in the future, but at least that I don't need to fix it right now. (sage-dev) ~/sage$ ./sage ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 10.7, Release Date: 2025-08-09 │ │ Using Python 3.12.11. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ sage: (sage-dev) ~/sage$ ./sage -pip show sagemath WARNING: Package(s) not found: sagemath (sage-dev) ~/sage$ sage ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 10.7, Release Date: 2025-08-09 │ │ Using Python 3.12.11. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ sage: from sagemath.check_version import check_version --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from sagemath.check_version import check_version ModuleNotFoundError: No module named 'sagemath' (sage-dev) ~/sage$ sage -pip install sagemath==1.3.0 Collecting sagemath==1.3.0 Installing collected packages: sagemath Successfully installed sagemath-1.3.0 (sage-dev) ~/sage$ ./sage ┌────────────────────────────────────────────────────────────────────┐ │ SageMath version 10.7, Release Date: 2025-08-09 │ │ Using Python 3.12.11. Type "help()" for help. │ └────────────────────────────────────────────────────────────────────┘ sage: from sagemath.check_version import check_version sage: check_version(">=10.8") /projects/e68a5dda-ac71-432d-99b7-c1bfecf6c804/miniforge3/envs/sage-dev/lib/python3.12/site-packages/sagemath/check_version.py:12: DeprecationWarning: Use sage.version instead. See https://github.com/sagemath/sage/issues/39015 for details. installed_version = sage_version_function().replace(',','').split()[2] --------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[2], line 1 ----> 1 check_version(">=10.8") File ~/miniforge3/envs/sage-dev/lib/python3.12/site-packages/sagemath/check_version.py:22, in check_version(version) 20 version = version.replace('>=','') 21 if parse_version(version) > parse_version(installed_version): ---> 22 raise ValueError("""\n******************************************************************\n 23 Sage version (= %s) is older than the required one (= %s)\n 24 ******************************************************************"""%(installed_version,version)) 25 elif version == '': 26 pass ValueError: ****************************************************************** Sage version (= 10.7) is older than the required one (= 10.8) ****************************************************************** sage: On Monday, 8 September 2025 at 08:50:47 UTC+2 dim...@gmail.com wrote: > Hi Maarten, > IMHO you'd need to update your package to work with modern setuptools > (no distutils). > Just think of sage as of a Python dependency. (It still works, in > fact, but this might not be > for too long). > > If one has Sage installed and running in a "usual" venv, then > installing your package breaks it, because it uninstalls sagemath and > "installs" meaningless sagemath 1.3.0. > > (sage-src) dima@tarski ~/software/sage-src $ ./sage # all works... > ┌────────────────────────────────────────────────────────────────────┐ > │ SageMath version 10.8.beta2, Release Date: 2025-09-07 │ > │ Using Python 3.13.5. Type "help()" for help. │ > └────────────────────────────────────────────────────────────────────┘ > ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ > ┃ Warning: this is a prerelease version, and it may be unstable. ┃ > ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ > sage: > (sage-src) dima@tarski ~/software/sage-src $ cd tmp > (sage-src) dima@tarski ~/software/sage-src/tmp $ git clone > g...@github.com:koffie/mdsage.git > Cloning into 'mdsage'... > [...] > (sage-src) dima@tarski ~/software/sage-src/tmp $ cd mdsage > (sage-src) dima@tarski ~/software/sage-src/tmp/mdsage $ uv pip install . > Using Python 3.13.5 environment at: /home/dima/software/sage-src/.venv > Resolved 3 packages in 484ms > Built mdsage @ file:///home/dima/software/sage-src/tmp/mdsage > Prepared 1 package in 159ms > Uninstalled 1 package in 37ms > Installed 2 packages in 9ms > + mdsage==0.1.0 (from file:///home/dima/software/sage-src/tmp/mdsage) > - sagemath==10.8b2 (from file:///home/dima/software/sage-src) > + sagemath==1.3.0 > (sage-src) dima@tarski ~/software/sage-src/tmp/mdsage $ ./sage > bash: ./sage: No such file or directory > (sage-src) dima@tarski ~/software/sage-src/tmp/mdsage $ cd ../../ > (sage-src) dima@tarski ~/software/sage-src $ ./sage # oops :-( > Traceback (most recent call last): > File "/home/dima/software/sage-src/src/bin/sage-ipython", line 9, in > <module> > from sage.misc.banner import banner > ModuleNotFoundError: No module named 'sage' > > > However, if I do the same, but with your requirements.txt removed, then > the above sequence just works. > > Moreover, tests pass (one fails due to a deprecation notice) > > $ ./sage -t tmp/mdsage/mdsage > Running doctests with ID 2025-09-07-21-50-34-567e0d32. > Git branch: HEAD > Git ref: 10.8.beta0-715-g31babe2a65d-dirty > Running with SAGE_LOCAL='/home/dima/software/sage-src/local' and > SAGE_VENV='/home/dima/software/sage-src/local/var/lib/sage/venv-python3.13' > Using --optional=gentoo,pip,sage > Features to be detected: > > 4ti2,SAGE_SRC,benzene,bliss,buckygen,conway_polynomials,coxeter3,csdp,cvxopt,cvxopt,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_cubic_hecke,database_ellcurves,database_graphs,database_jones_numfield,database_knotinfo,dot2tex,dvipng,ecm,flatter,fpylll,fricas,gap_package_atlasrep,gap_package_design,gap_package_grape,gap_package_guava,gap_package_hap,gap_package_polenta,gap_package_polycyclic,gap_package_qpa,gap_package_quagroup,gfan,giac,glucose,graphviz,imagemagick,info,ipython,jmol,jupymake,jupyter_sphinx,kenzo,khoca,kissat,latte_int,lrcalc_python,lrslib,mathics,matroid_database,mcqd,meataxe,meson_editable,mpmath,msolve,nauty,networkx,numpy,palp,pandoc,pdf2svg,pdftocairo,pexpect,phitigra,pillow,plantri,polytopes_db,polytopes_db_4d,pplpy,primecountpy,ptyprocess,pycosat,pycryptosat,pynormaliz,pyparsing,python_igraph,regina,requests,rpy2,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.groups,sage.libs.braiding,sage.libs.ecl,sage.libs.flint,sage.libs.gap,sage.libs.giac,sage.libs.homfly,sage.libs.linbox,sage.libs.m4ri,sage.libs.ntl,sage.libs.pari,sage.libs.singular,sage.misc.cython,sage.modular,sage.modules,sage.numerical.mip,sage.plot,sage.rings.complex_double,sage.rings.finite_rings,sage.rings.function_field,sage.rings.number_field,sage.rings.padics,sage.rings.polynomial.pbori,sage.rings.real_double,sage.rings.real_mpfr,sage.sat,sage.schemes,sage.symbolic,sage_numerical_backends_coin,sagemath_doc_html,scipy,singular,sirocco,sloane_database,sphinx,symengine_py,sympy,tdlib,threejs,topcom > Doctesting 14 files. > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/__init__.py > [0 tests, 0.00s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/canonical_rings.py > [14 tests, 0.40s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/congruence_subgroups.py > [6 tests, 1.14s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/cuspidal_classgroup.py > [17 tests, 1.54s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/kamiennys_criterion.py > ********************************************************************** > File "tmp/mdsage/mdsage/kamiennys_criterion.py", line 1079, in > mdsage.kamiennys_criterion.KamiennyCriterion.? > Failed example: > C.verify_criterion(4) > Expected: > (True, > 'All conditions are satified for Gamma1 d=4 p=43. Using n=5, > modp=65521, q=3 in Kamienny Version 1.5 and SageMath version ...', > [Vector space of degree 4 and dimension 0 over Finite Field of size 2 > Basis matrix: > [], Vector space of degree 23 and dimension 2 over Finite Field of size 2 > Basis matrix: > [1 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 0] > [0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0], Vector space of > degree 42 and dimension 11 over Finite Field of size 2 > Basis matrix: > [1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 > 1 1 0 0 1 1 1 1 1 1] > [0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 > 1 1 1 1 0 0 0 1 0 0] > [0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 > 0 0 0 0 1 1 0 0 1 0] > [0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 > 0 1 0 1 0 0 0 1 0 0] > [0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 > 0 1 0 0 0 0 0 0 0 0] > [0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 1 1 > 0 0 1 0 0 0 1 1 0 1] > [0 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 > 0 1 1 0 0 0 1 1 1 1] > [0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 > 0 0 0 0 1 1 0 0 0 0] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0 1 > 0 0 0 0 1 0 0 0 0 1] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 1 0 > 1 0 0 0 0 0 0 1 1 0] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 > 0 1 1 1 0 1 1 0 0 0]]) > Got: > doctest:warning > File "<doctest > mdsage.kamiennys_criterion.KamiennyCriterion.?[4]>", line 1, in > <module> > C.verify_criterion(Integer(4)) > File > "/home/dima/software/sage-src/.venv/lib/python3.13/site-packages/mdsage/kamiennys_criterion.py", > line 1131, in verify_criterion > % (self.congruence_type, d, self.p, n, p, q, Kamienny_Version, > version()), > File > "/home/dima/software/sage-src/.venv/lib/python3.13/site-packages/sage/misc/banner.py", > line 37, in version > deprecation(39015, "Use sage.version instead.") > File > "/home/dima/software/sage-src/.venv/lib/python3.13/site-packages/sage/misc/superseded.py", > line 99, in deprecation > warning(issue_number, message, DeprecationWarning, stacklevel) > File > "/home/dima/software/sage-src/.venv/lib/python3.13/site-packages/sage/misc/superseded.py", > line 180, in warning > warn(message, warning_class, stacklevel) > File "/usr/lib/python3.13/warnings.py", line 110, in _showwarnmsg > sw(msg.message, msg.category, msg.filename, msg.lineno, > : > DeprecationWarning: Use sage.version instead. > See https://github.com/sagemath/sage/issues/39015 for details. > (True, > 'All conditions are satified for Gamma1 d=4 p=43. Using n=5, > modp=65521, q=3 in Kamienny Version 1.5 and SageMath version > 10.8.beta2, Release Date: 2025-09-07', > [Vector space of degree 4 and dimension 0 over Finite Field of size 2 > Basis matrix: > [], > Vector space of degree 23 and dimension 2 over Finite Field of size 2 > Basis matrix: > [1 1 0 1 0 0 1 1 1 0 1 0 1 1 1 1 1 1 0 0 1 0 0] > [0 0 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 1 1 1 0 0 0], > Vector space of degree 42 and dimension 11 over Finite Field of size 2 > Basis matrix: > [1 0 0 0 0 0 0 1 0 1 1 1 0 1 1 0 1 0 1 0 1 0 0 0 0 0 1 0 1 0 0 0 > 1 1 0 0 1 1 1 1 1 1] > [0 1 0 0 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0 0 1 0 0 0 > 1 1 1 1 0 0 0 1 0 0] > [0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 0 0 0 1 1 1 > 0 0 0 0 1 1 0 0 1 0] > [0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 0 1 1 0 0 1 0 0 0 > 0 1 0 1 0 0 0 1 0 0] > [0 0 0 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 > 0 1 0 0 0 0 0 0 0 0] > [0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 1 1 > 0 0 1 0 0 0 1 1 0 1] > [0 0 0 0 0 0 1 0 0 0 1 0 1 1 1 0 1 1 0 1 0 0 1 0 0 0 1 0 1 0 1 0 > 0 1 1 0 0 0 1 1 1 1] > [0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 > 0 0 0 0 1 1 0 0 0 0] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 0 1 > 0 0 0 0 1 0 0 0 0 1] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 1 0 > 1 0 0 0 0 0 0 1 1 0] > [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 > 0 1 1 1 0 1 1 0 0 0]]) > ********************************************************************** > 1 item had failures: > 1 of 12 in mdsage.kamiennys_criterion.KamiennyCriterion.? > [64 tests, 1 failure, 2.63s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/maartens_sage_functions.py > [28 tests, 0.31s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/modular_degrees_oldforms.py > [28 tests, 1.17s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/modular_unit_divisors.py > [2 tests, 0.01s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/one_cython_file.pyx > [4 tests, 0.01s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/quadratic_class_numbers.py > [17 tests, 0.91s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/ramification.py > [12 tests, 1.85s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/sage_bugs.py > [0 tests, 0.00s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/ultimate_question.py > [7 tests, 0.01s wall] > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/utilities.py > [12 tests, 0.19s wall] > ---------------------------------------------------------------------- > sage-runtests --warn-long 5.0 > --random-seed=177091587185286457373292283220227525984 > tmp/mdsage/mdsage/kamiennys_criterion.py # 1 doctest failed > ---------------------------------------------------------------------- > Total time for all tests: 10.5 seconds > cpu time: 9.8 seconds > cumulative wall time: 10.2 seconds > Features detected for doctesting: > (sage-src) dima@tarski ~/software/sage-src $ > > HTH > Dima > > On Sat, Sep 6, 2025 at 8:34 PM Maarten Derickx > <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+...@googlegroups.com. > > To view this discussion visit > https://groups.google.com/d/msgid/sage-devel/7f8aef4e-4d47-4692-89eb-ad90c93a4febn%40googlegroups.com > . > -- 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/440851be-6bf4-46c9-b882-5462ef75ec41n%40googlegroups.com.