Detecting external software#

This module makes up a list of external software that Sage interfaces. Availability of each software is tested only when necessary. This is mainly used for the doctests which require certain external software installed on the system.

Even though the functions in this module should also work when an external software is not present, most doctests in this module are only tested if testing of external software is explicitly enabled in order to avoid invoking external software otherwise. See Issue #28819 for details.

AUTHORS:

  • Kwankyu Lee (2016-03-09) – initial version, based on code by Robert Bradshaw and Nathann Cohen

class sage.doctest.external.AvailableSoftware[source]#

Bases: object

This class keeps the set of available software whose availability is detected lazily from the list of external software.

EXAMPLES:

sage: from sage.doctest.external import external_software, available_software
sage: external_software
['cplex',
 'dvips',
 'ffmpeg',
 'gurobi',
 'internet',
 'latex',
 'latex_package_tkz_graph',
 'lualatex',
 'macaulay2',
 'magma',
 'maple',
 'mathematica',
 'matlab',
 'octave',
 'pdflatex',
 'scilab',
 'xelatex']
sage: 'internet' in available_software # random, optional - internet
True
sage: available_software.issuperset(set(['internet','latex'])) # random, optional - internet latex
True
>>> from sage.all import *
>>> from sage.doctest.external import external_software, available_software
>>> external_software
['cplex',
 'dvips',
 'ffmpeg',
 'gurobi',
 'internet',
 'latex',
 'latex_package_tkz_graph',
 'lualatex',
 'macaulay2',
 'magma',
 'maple',
 'mathematica',
 'matlab',
 'octave',
 'pdflatex',
 'scilab',
 'xelatex']
>>> 'internet' in available_software # random, optional - internet
True
>>> available_software.issuperset(set(['internet','latex'])) # random, optional - internet latex
True
detectable()[source]#

Return the list of names of those features for which testing their presence is allowed.

hidden()[source]#

Return the list of detected hidden external software.

EXAMPLES:

sage: # needs conway_polynomials database_cremona_mini_ellcurve database_ellcurves database_graphs
sage: from sage.doctest.external import available_software
sage: from sage.features.databases import all_features
sage: for f in all_features():
....:    f.hide()
....:    if f._spkg_type() == 'standard':
....:         test = f.name in available_software
....:    f.unhide()
sage: sorted(available_software.hidden())
[...'conway_polynomials',...
 'database_cremona_mini_ellcurve',...
 'database_ellcurves',...
 'database_graphs'...]
>>> from sage.all import *
>>> # needs conway_polynomials database_cremona_mini_ellcurve database_ellcurves database_graphs
>>> from sage.doctest.external import available_software
>>> from sage.features.databases import all_features
>>> for f in all_features():
...    f.hide()
...    if f._spkg_type() == 'standard':
...         test = f.name in available_software
...    f.unhide()
>>> sorted(available_software.hidden())
[...'conway_polynomials',...
 'database_cremona_mini_ellcurve',...
 'database_ellcurves',...
 'database_graphs'...]
issuperset(other)[source]#

Return True if other is a subset of self.

EXAMPLES:

sage: from sage.doctest.external import available_software
sage: available_software.issuperset(set(['internet','latex','magma'])) # random, optional - internet latex magma
True
>>> from sage.all import *
>>> from sage.doctest.external import available_software
>>> available_software.issuperset(set(['internet','latex','magma'])) # random, optional - internet latex magma
True
seen()[source]#

Return the list of detected external software.

EXAMPLES:

sage: from sage.doctest.external import available_software
sage: available_software.seen() # random
['internet', 'latex', 'magma']
>>> from sage.all import *
>>> from sage.doctest.external import available_software
>>> available_software.seen() # random
['internet', 'latex', 'magma']
sage.doctest.external.external_features()[source]#

Generate the features that are only to be tested if --optional=external is used.

EXAMPLES:

sage: from sage.doctest.external import external_features
sage: next(external_features())
Feature('internet')
>>> from sage.all import *
>>> from sage.doctest.external import external_features
>>> next(external_features())
Feature('internet')
sage.doctest.external.has_4ti2()[source]#

Test if the 4ti2 package is available.

EXAMPLES:

sage: from sage.doctest.external import has_4ti2
sage: has_4ti2()   # optional -- 4ti2
FeatureTestResult('4ti2', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_4ti2
>>> has_4ti2()   # optional -- 4ti2
FeatureTestResult('4ti2', True)
sage.doctest.external.has_cplex()[source]#

Test if CPLEX is available.

EXAMPLES:

sage: from sage.doctest.external import has_cplex
sage: has_cplex() # random, optional - CPLEX
FeatureTestResult('cplex', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_cplex
>>> has_cplex() # random, optional - CPLEX
FeatureTestResult('cplex', True)
sage.doctest.external.has_dvipng()[source]#

Test if dvipng is available.

EXAMPLES:

sage: from sage.doctest.external import has_dvipng
sage: has_dvipng() # optional -- dvipng
FeatureTestResult('dvipng', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_dvipng
>>> has_dvipng() # optional -- dvipng
FeatureTestResult('dvipng', True)
sage.doctest.external.has_ffmpeg()[source]#

Test if ffmpeg is available.

EXAMPLES:

sage: from sage.doctest.external import has_ffmpeg
sage: has_ffmpeg()      # optional -- ffmpeg
FeatureTestResult('ffmpeg', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_ffmpeg
>>> has_ffmpeg()      # optional -- ffmpeg
FeatureTestResult('ffmpeg', True)
sage.doctest.external.has_graphviz()[source]#

Test if graphviz (dot, twopi, neato) are available.

EXAMPLES:

sage: from sage.doctest.external import has_graphviz
sage: has_graphviz()   # optional -- graphviz
FeatureTestResult('graphviz', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_graphviz
>>> has_graphviz()   # optional -- graphviz
FeatureTestResult('graphviz', True)
sage.doctest.external.has_gurobi()[source]#

Test if Gurobi is available.

EXAMPLES:

sage: from sage.doctest.external import has_gurobi
sage: has_gurobi() # random, optional - Gurobi
FeatureTestResult('gurobi', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_gurobi
>>> has_gurobi() # random, optional - Gurobi
FeatureTestResult('gurobi', True)
sage.doctest.external.has_imagemagick()[source]#

Test if ImageMagick (command magick or convert) is available.

EXAMPLES:

sage: from sage.doctest.external import has_imagemagick
sage: has_imagemagick() # optional -- imagemagick
FeatureTestResult('imagemagick', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_imagemagick
>>> has_imagemagick() # optional -- imagemagick
FeatureTestResult('imagemagick', True)
sage.doctest.external.has_internet()[source]#

Test if Internet is available.

Failure of connecting to the site “https://www.sagemath.org” within a second is regarded as internet being not available.

EXAMPLES:

sage: from sage.doctest.external import has_internet
sage: has_internet()  # random, optional -- internet
FeatureTestResult('internet', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_internet
>>> has_internet()  # random, optional -- internet
FeatureTestResult('internet', True)
sage.doctest.external.has_latex()[source]#

Test if Latex is available.

EXAMPLES:

sage: from sage.doctest.external import has_latex
sage: has_latex() # optional - latex
FeatureTestResult('latex', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_latex
>>> has_latex() # optional - latex
FeatureTestResult('latex', True)
sage.doctest.external.has_lualatex()[source]#

Test if lualatex is available.

EXAMPLES:

sage: from sage.doctest.external import has_lualatex
sage: has_lualatex()   # optional - lualatex
FeatureTestResult('lualatex', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_lualatex
>>> has_lualatex()   # optional - lualatex
FeatureTestResult('lualatex', True)
sage.doctest.external.has_macaulay2()[source]#

Test if Macaulay2 is available.

EXAMPLES:

sage: from sage.doctest.external import has_macaulay2
sage: has_macaulay2() # random, optional - macaulay2
True
>>> from sage.all import *
>>> from sage.doctest.external import has_macaulay2
>>> has_macaulay2() # random, optional - macaulay2
True
sage.doctest.external.has_magma()[source]#

Test if Magma is available.

EXAMPLES:

sage: from sage.doctest.external import has_magma
sage: has_magma() # random, optional - magma
True
>>> from sage.all import *
>>> from sage.doctest.external import has_magma
>>> has_magma() # random, optional - magma
True
sage.doctest.external.has_maple()[source]#

Test if Maple is available.

EXAMPLES:

sage: from sage.doctest.external import has_maple
sage: has_maple() # random, optional - maple
True
>>> from sage.all import *
>>> from sage.doctest.external import has_maple
>>> has_maple() # random, optional - maple
True
sage.doctest.external.has_mathematica()[source]#

Test if Mathematica is available.

EXAMPLES:

sage: from sage.doctest.external import has_mathematica
sage: has_mathematica() # random, optional - mathematica
True
>>> from sage.all import *
>>> from sage.doctest.external import has_mathematica
>>> has_mathematica() # random, optional - mathematica
True
sage.doctest.external.has_matlab()[source]#

Test if Matlab is available.

EXAMPLES:

sage: from sage.doctest.external import has_matlab
sage: has_matlab() # random, optional - matlab
True
>>> from sage.all import *
>>> from sage.doctest.external import has_matlab
>>> has_matlab() # random, optional - matlab
True
sage.doctest.external.has_octave()[source]#

Test if Octave is available.

EXAMPLES:

sage: from sage.doctest.external import has_octave
sage: has_octave() # random, optional - octave
True
>>> from sage.all import *
>>> from sage.doctest.external import has_octave
>>> has_octave() # random, optional - octave
True
sage.doctest.external.has_pandoc()[source]#

Test if pandoc is available.

EXAMPLES:

sage: from sage.doctest.external import has_pandoc
sage: has_pandoc()      # optional -- pandoc
FeatureTestResult('pandoc', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_pandoc
>>> has_pandoc()      # optional -- pandoc
FeatureTestResult('pandoc', True)
sage.doctest.external.has_pdf2svg()[source]#

Test if pdf2svg is available.

EXAMPLES:

sage: from sage.doctest.external import has_pdf2svg
sage: has_pdf2svg() # optional -- pdf2svg
FeatureTestResult('pdf2svg', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_pdf2svg
>>> has_pdf2svg() # optional -- pdf2svg
FeatureTestResult('pdf2svg', True)
sage.doctest.external.has_pdflatex()[source]#

Test if pdflatex is available.

EXAMPLES:

sage: from sage.doctest.external import has_pdflatex
sage: has_pdflatex()   # optional - pdflatex
FeatureTestResult('pdflatex', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_pdflatex
>>> has_pdflatex()   # optional - pdflatex
FeatureTestResult('pdflatex', True)
sage.doctest.external.has_rubiks()[source]#

Test if the rubiks package (cu2, cubex, dikcube, mcube, optimal, and size222) is available.

EXAMPLES:

sage: from sage.doctest.external import has_rubiks
sage: has_rubiks()   # optional -- rubiks
FeatureTestResult('rubiks', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_rubiks
>>> has_rubiks()   # optional -- rubiks
FeatureTestResult('rubiks', True)
sage.doctest.external.has_scilab()[source]#

Test if Scilab is available.

EXAMPLES:

sage: from sage.doctest.external import has_scilab
sage: has_scilab() # random, optional - scilab
True
>>> from sage.all import *
>>> from sage.doctest.external import has_scilab
>>> has_scilab() # random, optional - scilab
True
sage.doctest.external.has_xelatex()[source]#

Test if xelatex is available.

EXAMPLES:

sage: from sage.doctest.external import has_xelatex
sage: has_xelatex()   # optional - xelatex
FeatureTestResult('xelatex', True)
>>> from sage.all import *
>>> from sage.doctest.external import has_xelatex
>>> has_xelatex()   # optional - xelatex
FeatureTestResult('xelatex', True)