Skip to content

Use 'python -m sage.doctest' instead of 'sage -t' #40236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025

Conversation

tobiasdiez
Copy link
Contributor

Since sage -t is not working with meson. Progress towards #39875 (not sure if I got all of them).

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

Copy link

github-actions bot commented Jun 9, 2025

Documentation preview for this PR (built with commit d0d96e3; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@user202729
Copy link
Contributor

user202729 commented Jun 9, 2025

But sage -t works on my machine just fine?

Edit: okay I see the context, it's only when you install it instead of running from source tree.

@antonio-rojas
Copy link
Contributor

IIRC sage-the-distro's python (and possibly other distros) doesn't ship the python→python3 symlink, so we should be using the python3 command consistently.

Side note: as long as sage-the-distro allows installing its own Python, it should be CI tested, which doesn't seem to be the case currently.

@user202729
Copy link
Contributor

as long as sage -t is supported, surely it should be tested somewhere? What if some future change break it and some developers workflow is affected?

If you want to unsupport sage -t and ask them to migrate to python -m something… possible but you may want to announce it first.

@antonio-rojas
Copy link
Contributor

as long as sage -t is supported, surely it should be tested somewhere? What if some future change break it and some developers workflow is affected?

If you want to unsupport sage -t and ask them to migrate to python -m something… possible but you may want to announce it first.

It is still being tested in sage/tests/cmdline.py (which is the natural place to do so). By the way, that file should not be installed by meson.

@antonio-rojas
Copy link
Contributor

antonio-rojas commented Jun 10, 2025

This fixes doctesting the sage/doctest dir for me in an installed, meson-built sage. However, the doctesting output still displays sage -t:

> python -m sage.doctest /usr/lib/python3.13/site-packages/sage/doctest 
Running doctests with ID 2025-06-10-13-55-18-e5673ad5.
Running with SAGE_LOCAL='/usr' and SAGE_VENV='/usr'
Using --optional=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,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,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,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 15 files.
sage -t --warn-long 5.0 --random-seed=214446839433195787860917771076279359673 /usr/lib/python3.13/site-packages/sage/doctest/test.py
    [24 tests, 0.49s wall]
sage -t --warn-long 5.0 --random-seed=214446839433195787860917771076279359673 /usr/lib/python3.13/site-packages/sage/doctest/check_tolerance.py
    [19 tests, 0.02s wall]
[...]

@antonio-rojas
Copy link
Contributor

Nevermind, I forgot to pass -l when testing. There are still a few failures:

**********************************************************************
File "src/sage/src/sage/doctest/test.py", line 241, in sage.doctest.test
Failed example:
    subprocess.call(["sage", "-tp", "1000000", "--timeout=120",  # long time
         "--die_timeout=10", "--optional=sage",
         "--warn-long", "0", "99seconds.rst", "interrupt_diehard.rst"], **kwds2)
Expected:
    Running doctests...
    Doctesting 2 files using 1000000 threads...
    Killing test 99seconds.rst
    Killing test interrupt_diehard.rst
    ----------------------------------------------------------------------
    Doctests interrupted: 0/2 files tested
    ----------------------------------------------------------------------
    ...
    128
Got:
    usage: sage [-h] [-v] [-q] [--simple-prompt] [-V] [-n [{jupyter,jupyterlab}]]
                [-c [COMMAND]]
                [file]
    sage: error: unrecognized arguments: -tp --timeout=120 --die_timeout=10 --optional=sage --warn-long 0 99seconds.rst interrupt_diehard.rst
    2
**********************************************************************
File "src/sage/src/sage/doctest/test.py", line 259, in sage.doctest.test
Failed example:
    pid = int(open(F).read())
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.doctest.test[25]>", line 1, in <module>
        pid = int(open(F).read())
    ValueError: invalid literal for int() with base 10: ''
**********************************************************************
File "src/sage/src/sage/doctest/test.py", line 261, in sage.doctest.test
Failed example:
    os.kill(pid, signal.SIGQUIT)  # 2 seconds passed => still alive
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.doctest.test[27]>", line 1, in <module>
        os.kill(pid, signal.SIGQUIT)  # 2 seconds passed => still alive
                ^^^
    NameError: name 'pid' is not defined
**********************************************************************
File "src/sage/src/sage/doctest/test.py", line 263, in sage.doctest.test
Failed example:
    os.kill(pid, signal.SIGQUIT)  # 10 seconds passed => dead  # random
Expected:
    Traceback (most recent call last):
    ...
    ProcessLookupError: ...
Got:
    <BLANKLINE>
    Traceback (most recent call last):
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 730, in _run
        self.compile_and_execute(example, compiler, test.globs)
        ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.13/site-packages/sage/doctest/forker.py", line 1154, in compile_and_execute
        exec(compiled, globs)
        ~~~~^^^^^^^^^^^^^^^^^
      File "<doctest sage.doctest.test[29]>", line 1, in <module>
        os.kill(pid, signal.SIGQUIT)  # 10 seconds passed => dead  # random
                ^^^
    NameError: name 'pid' is not defined
**********************************************************************
1 item had failures:
   4 of  56 in sage.doctest.test
    [55 tests, 4 failures, 175.01s wall]
----------------------------------------------------------------------
sage -t --long --warn-long 30.0 --random-seed=150612886400060636501286193160487656764 src/sage/src/sage/doctest/test.py  # 4 doctests failed
----------------------------------------------------------------------

@tobiasdiez
Copy link
Contributor Author

IIRC sage-the-distro's python (and possibly other distros) doesn't ship the python→python3 symlink, so we should be using the python3 command consistently.

Right, forgot about this one. Thanks!

as long as sage -t is supported, surely it should be tested somewhere? What if some future change break it and some developers workflow is affected?

If you want to unsupport sage -t and ask them to migrate to python -m something… possible but you may want to announce it first.

./sage -t is still used in CI to run the tests, that should give enough confidence that it's not broken. Moreover, sage -t just directs to sage-runtest which is a 3 line wrapper doing exactly the same as python -m sage.doctest.
I hope we can deprecate sage's custom doctester relatively soon and just use pytest instead.

Nevermind, I forgot to pass -l when testing. There are still a few failures:

Should be fixed now, at least partly. One of these tests uses tempfile which for some reason is not working well for the meson build (and should be replaced by built-in python functions anyway).

@antonio-rojas
Copy link
Contributor

LGTM now

vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 15, 2025
sagemathgh-40236: Use 'python -m sage.doctest' instead of 'sage -t'
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Since `sage -t` is not working with meson. Progress towards
sagemath#39875 (not sure if I got all of
them).


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40236
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 17, 2025
sagemathgh-40236: Use 'python -m sage.doctest' instead of 'sage -t'
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Since `sage -t` is not working with meson. Progress towards
sagemath#39875 (not sure if I got all of
them).


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40236
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 18, 2025
sagemathgh-40236: Use 'python -m sage.doctest' instead of 'sage -t'
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Since `sage -t` is not working with meson. Progress towards
sagemath#39875 (not sure if I got all of
them).


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40236
Reported by: Tobias Diez
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jun 21, 2025
sagemathgh-40236: Use 'python -m sage.doctest' instead of 'sage -t'
    
<!-- ^ Please provide a concise and informative title. -->
<!-- ^ Don't put issue numbers in the title, do this in the PR
description below. -->
<!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method
to calculate 1 + 2". -->
<!-- v Describe your changes below in detail. -->
<!-- v Why is this change required? What problem does it solve? -->
<!-- v If this PR resolves an open issue, please link to it here. For
example, "Fixes sagemath#12345". -->

Since `sage -t` is not working with meson. Progress towards
sagemath#39875 (not sure if I got all of
them).


### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#40236
Reported by: Tobias Diez
Reviewer(s):
@vbraun vbraun merged commit 2cc817d into sagemath:develop Jun 25, 2025
23 checks passed
antonio-rojas added a commit to antonio-rojas/sage that referenced this pull request Jul 25, 2025
Like it's done in all other tests in this file since sagemath#40236

`sage -t` does not exist in meson-built sage
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 26, 2025
sagemathgh-40477: Use `python -m sage.doctest` to run the doctester
    
Like it's done in all other tests in this file since
sagemath#40236

`sage -t` does not exist in meson-built sage
    
URL: sagemath#40477
Reported by: Antonio Rojas
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 27, 2025
sagemathgh-40477: Use `python -m sage.doctest` to run the doctester
    
Like it's done in all other tests in this file since
sagemath#40236

`sage -t` does not exist in meson-built sage
    
URL: sagemath#40477
Reported by: Antonio Rojas
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 28, 2025
sagemathgh-40477: Use `python -m sage.doctest` to run the doctester
    
Like it's done in all other tests in this file since
sagemath#40236

`sage -t` does not exist in meson-built sage
    
URL: sagemath#40477
Reported by: Antonio Rojas
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Jul 29, 2025
sagemathgh-40477: Use `python -m sage.doctest` to run the doctester
    
Like it's done in all other tests in this file since
sagemath#40236

`sage -t` does not exist in meson-built sage
    
URL: sagemath#40477
Reported by: Antonio Rojas
Reviewer(s):
vbraun pushed a commit to vbraun/sage that referenced this pull request Aug 1, 2025
sagemathgh-40477: Use `python -m sage.doctest` to run the doctester
    
Like it's done in all other tests in this file since
sagemath#40236

`sage -t` does not exist in meson-built sage
    
URL: sagemath#40477
Reported by: Antonio Rojas
Reviewer(s):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants