sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.39k stars 473 forks source link

Features for latex packages #32926

Closed mkoeppe closed 2 years ago

mkoeppe commented 2 years ago

Add Features LaTeXPackage to detect presence of latex packages.

Depends on #32174

CC: @seblabbe @kwankyu

Component: refactoring

Author: Matthias Koeppe

Branch: e22c173

Reviewer: Kwankyu Lee, Sébastien Labbé

Issue created by migration from https://trac.sagemath.org/ticket/32926

mkoeppe commented 2 years ago

Branch: u/mkoeppe/features_for_latex_packages

mkoeppe commented 2 years ago

Dependencies: #32174

mkoeppe commented 2 years ago

Last 10 new commits:

12f7c98src/sage/features/polymake.py: Add all_features
c9312dbsrc/sage/features: Add more all_features functions
230d135src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py: Fix doctest markup
7a8f48csrc/sage/features/sagemath.py (sage_features): Unused now, removed
e7f538dsage.features.bliss: Change name of BlissLibrary feature to libbliss, remove it from all_features
12a2507src/sage/features/interfaces.py: Fix indentation in docstring
0dd76b6Merge tag '9.5.beta7' into t/32174/doctests__detect__safe__external_features_even_if____optional_external__is_not_used
07b2512src/sage/misc/latex.py: Conditionalize some doctests on latex_package_tkz_graph
2dd9ad3Merge #32174
42d35b0src/sage/features/latex.py (TeXFile, LaTeXPackage, 'latex_package_tkz_graph'): New
mkoeppe commented 2 years ago

Commit: 42d35b0

seblabbe commented 2 years ago
comment:4

When testing the feature, I get:

NameError: name 'FeatureNotPresentError' is not defined

an import is missing.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

da1e922src/sage/features/latex.py: Add missing import
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 42d35b0 to da1e922

kwankyu commented 2 years ago
comment:8
diff --git a/src/sage/features/latex.py b/src/sage/features/latex.py
index 7b95796be4..7bd8d72164 100644
--- a/src/sage/features/latex.py
+++ b/src/sage/features/latex.py
@@ -147,7 +147,7 @@ class TeXFile(StaticFile):
         sage: from sage.features.latex import TeXFile
         sage: TeXFile('x', 'x.tex').is_present()  # optional: pdflatex
         FeatureTestResult('x', True)
-        sage: TeXFile('nonexisting', 'fajfhjdksf-nonexisting-file.tex').is_present()  # optional: pdflatex
+        sage: TeXFile('nonexisting', 'xxxxxx-nonexisting-file.tex').is_present()  # optional - pdflatex
         FeatureTestResult('nonexisting', False)
     """
     def __init__(self, name, filename, **kwds):
@@ -161,7 +161,7 @@ class TeXFile(StaticFile):

             sage: from sage.features.latex import TeXFile
             sage: feature = TeXFile('latex_class_article', 'article.cls')
-            sage: feature.absolute_path()  # optional: pdflatex
+            sage: feature.absolute_path()  # optional - pdflatex
             '.../latex/base/article.cls'
         """
         from subprocess import run, CalledProcessError, PIPE
@@ -183,7 +183,7 @@ class LaTeXPackage(TeXFile):
     EXAMPLES::

         sage: from sage.features.latex import LaTeXPackage
-        sage: LaTeXPackage('graphics').is_present()  # optional: pdflatex
+        sage: LaTeXPackage('graphics').is_present()  # optional - pdflatex
         FeatureTestResult('latex_package_graphics', True)
     """
     @staticmethod

Otherwise, looks good to me.

kwankyu commented 2 years ago

Reviewer: Kwankyu Lee

mkoeppe commented 2 years ago
comment:10

I agree with these changes, please push them to the ticket

kwankyu commented 2 years ago

Changed branch from u/mkoeppe/features_for_latex_packages to public/32926

kwankyu commented 2 years ago

Changed commit from da1e922 to none

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Commit: ddac7bc

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

230d135src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py: Fix doctest markup
7a8f48csrc/sage/features/sagemath.py (sage_features): Unused now, removed
e7f538dsage.features.bliss: Change name of BlissLibrary feature to libbliss, remove it from all_features
12a2507src/sage/features/interfaces.py: Fix indentation in docstring
0dd76b6Merge tag '9.5.beta7' into t/32174/doctests__detect__safe__external_features_even_if____optional_external__is_not_used
07b2512src/sage/misc/latex.py: Conditionalize some doctests on latex_package_tkz_graph
2dd9ad3Merge #32174
42d35b0src/sage/features/latex.py (TeXFile, LaTeXPackage, 'latex_package_tkz_graph'): New
da1e922src/sage/features/latex.py: Add missing import
ddac7bcSmall edits
kwankyu commented 2 years ago
comment:13

Okay. Done.

kwankyu commented 2 years ago
comment:15

Let's wait for the patchbot run once more.

seblabbe commented 2 years ago
comment:16

There are latex related failures on the patchbot, that may be caused by this ticket:

Using --optional=build,debian,dochtml,pip,sage,sage_spkg
Features to be detected: 4ti2,benzene,bliss,buckygen,conway_polynomials,csdp,database_cremona_ellcurve,database_cremona_mini_ellcurve,database_jones_numfield,database_knotinfo,dvipng,ffmpeg,graphviz,imagemagick,jupymake,kenzo,latex,latex_package_tkz_graph,latte_int,lrslib,lualatex,mcqd,meataxe,pandoc,pdf2svg,pdflatex,plantri,pynormaliz,rubiks,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.plot,sage.rings.number_field,sage.rings.real_double,sage.symbolic,sage_numerical_backends_coin,tdlib,xelatex
...
----------------------------------------------------------------------
sage -t --long --random-seed=178499729190442340371727389632049879918 src/sage/plot/plot.py  # 89 doctests failed
sage -t --long --random-seed=178499729190442340371727389632049879918 src/sage/plot/graphics.py  # 63 doctests failed
sage -t --long --random-seed=178499729190442340371727389632049879918 src/sage/misc/latex.py  # 1 doctest failed
----------------------------------------------------------------------
Features detected for doctesting: 4ti2,dvipng,ffmpeg,graphviz,latex,latex_package_tkz_graph,lrslib,lualatex,pdflatex,sage.combinat,sage.geometry.polyhedron,sage.graphs,sage.plot,sage.rings.number_field,sage.rings.real_double,sage.symbolic,xelatex

in particular:

sage -t --long --random-seed=178499729190442340371727389632049879918 src/sage/misc/latex.py
**********************************************************************
File "src/sage/misc/latex.py", line 1968, in sage.misc.latex.?
Failed example:
    png(ZZ[x], os.path.join(SAGE_TMP, "zz.png")) # random, optional - latex
Exception raised:
    Traceback (most recent call last):
      File "/home/debian/sage/local/lib/python3.9/site-packages/sage/doctest/forker.py", line 694, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/debian/sage/local/lib/python3.9/site-packages/sage/doctest/forker.py", line 1088, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.misc.latex.?[1]>", line 1, in <module>
        png(ZZ[x], os.path.join(SAGE_TMP, "zz.png")) # random, optional - latex
      File "/home/debian/sage/local/lib/python3.9/site-packages/sage/misc/latex.py", line 1990, in png
        e = _run_latex_(tex_file, density=density, debug=debug,
      File "/home/debian/sage/local/lib/python3.9/site-packages/sage/misc/latex.py", line 755, in _run_latex_
        ImageMagick().require()
      File "/home/debian/sage/local/lib/python3.9/site-packages/sage/features/__init__.py", line 205, in require
        raise FeatureNotPresentError(self, presence.reason, presence.resolution)
    sage.features.FeatureNotPresentError: imagemagick is not available.
    Executable 'convert' not found on PATH.
    To install imagemagick using the debian package manager, you can try to run:
    !sudo apt-get update 
      !sudo apt-get install  texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev
    To install imagemagick using the Sage package manager, you can try to run:
      !sage -i _recommended
    No equivalent system packages for pip are known to Sage.
    Further installation instructions might be available at https://www.imagemagick.org/.
**********************************************************************
1 item had failures:
   1 of  19 in sage.misc.latex.?
    [257 tests, 1 failure, 5.09 s]

Also notice:

To install imagemagick using the debian package manager, you can try to run:
    !sudo apt-get update 
    !sudo apt-get install  texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev
mkoeppe commented 2 years ago
comment:17

This failure in testing src/sage/misc/latex.py is probably already visible with #32174.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

60bdd71sage.misc.latex.png: Mark doctest # optional - imagemagick
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from ddac7bc to 60bdd71

mkoeppe commented 2 years ago
comment:19

Not sure what's going on in the other failures in sage.plot.

seblabbe commented 2 years ago
comment:20

(This comment was moved to #32174 comment:56)

seblabbe commented 2 years ago
comment:21

Replying to @mkoeppe:

This failure in testing src/sage/misc/latex.py is probably already visible with #32174.

Ok, so I confirm that the 89 + 63 failures are already seen by the patchbot labri-vindelecroix-1 while testing #32174, so it is not related to the current ticket.

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 60bdd71 to 140575c

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

cb1343732174: fix the --show-skipped doctest report
391dca1sage.misc.latex.png: Mark doctest # optional - imagemagick
6f311b3src/sage/doctest/external.py: Revert latex features to 'external'
3bfe1a132174: adapting the doctest listing external softwares
e41cf29src/sage/features/latex.py (TeXFile, LaTeXPackage, 'latex_package_tkz_graph'): New
8d875d5src/sage/features/latex.py: Add missing import
140575cSmall edits
mkoeppe commented 2 years ago
comment:23

rebased on top of updated #32174

seblabbe commented 2 years ago
comment:24

Replying to @seblabbe:

Also notice:

To install imagemagick using the debian package manager, you can try to run:
    !sudo apt-get update 
    !sudo apt-get install  texlive-latex-extra texlive-xetex latexmk dvipng default-jdk ffmpeg libavdevice-dev

See #32956 to deal with that.

kwankyu commented 2 years ago

Changed reviewer from Kwankyu Lee to Kwankyu Lee; Sébastien Labbé

kwankyu commented 2 years ago
comment:25

No more thing to do here. Right?

slel commented 2 years ago
comment:26

Maybe a short ticket description?

E.g. is there a meta-ticket or documentation page or release tour item about "features"?

Other than that, this ticket depends on #32174 which still needs review.

kwankyu commented 2 years ago
comment:27

Okay then.

kwankyu commented 2 years ago

Description changed:

--- 
+++ 
@@ -1 +1 @@
-
+Add Features `LaTeXPackage` to detect presence of latex packages.
kwankyu commented 2 years ago
comment:30

As the dependency #32174 just got positive review.

vbraun commented 2 years ago
comment:31
sage -t --long --warn-long 41.2 --random-seed=90818346224792411697676027482246961463 src/sage/doctest/external.py
**********************************************************************
File "src/sage/doctest/external.py", line 379, in sage.doctest.external.AvailableSoftware
Failed example:
    external_software
Expected:
    ['cplex',
     'gurobi',
     'internet',
     'latex',
     'lualatex',
     'macaulay2',
     'magma',
     'maple',
     'mathematica',
     'matlab',
     'octave',
     'pdflatex',
     'scilab',
     'xelatex']
Got:
    ['cplex',
     'gurobi',
     'internet',
     'latex',
     'latex_package_tkz_graph',
     'lualatex',
     'macaulay2',
     'magma',
     'maple',
     'mathematica',
     'matlab',
     'octave',
     'pdflatex',
     'scilab',
     'xelatex']
**********************************************************************
1 item had failures:
   1 of   3 in sage.doctest.external.AvailableSoftware
    [40 tests, 1 failure, 0.02 s]
7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Changed commit from 140575c to e22c173

7ed8c4ca-6d56-4ae9-953a-41e42b4ed313 commented 2 years ago

Branch pushed to git repo; I updated commit sha1. New commits:

29a0750Merge tag '9.5.beta8' into t/32926/public/32926
e22c173src/sage/doctest/external.py: Update doctest output
vbraun commented 2 years ago

Changed branch from public/32926 to e22c173

mkoeppe commented 2 years ago

Changed commit from e22c173 to none

mkoeppe commented 2 years ago

Changed reviewer from Kwankyu Lee; Sébastien Labbé to Kwankyu Lee, Sébastien Labbé