|
| 1 | +r""" |
| 2 | +Check for SageMath Python modules |
| 3 | +""" |
| 4 | +from . import PythonModule |
| 5 | + |
| 6 | + |
| 7 | +class sage__combinat(PythonModule): |
| 8 | + |
| 9 | + def __init__(self): |
| 10 | + # sage.combinat will be a namespace package. |
| 11 | + # Testing whether sage.combinat itself can be imported is meaningless. |
| 12 | + # Hence, we test a Python module within the package. |
| 13 | + PythonModule.__init__(self, 'sage.combinat.combinations') |
| 14 | + |
| 15 | + |
| 16 | +class sage__graphs(PythonModule): |
| 17 | + |
| 18 | + def __init__(self): |
| 19 | + PythonModule.__init__(self, 'sage.graphs.graph') |
| 20 | + |
| 21 | + |
| 22 | +class sage__rings__real_double(PythonModule): |
| 23 | + |
| 24 | + def __init__(self): |
| 25 | + PythonModule.__init__(self, 'sage.rings.real_double') |
| 26 | + |
| 27 | + |
| 28 | +class sage__symbolic(PythonModule): |
| 29 | + |
| 30 | + def __init__(self): |
| 31 | + PythonModule.__init__(self, 'sage.symbolic.expression', spkg="sagemath_symbolics") |
| 32 | + |
| 33 | + |
| 34 | +def sage_optional_tags(): |
| 35 | + """ |
| 36 | + Return tags for conditionalizing doctests. |
| 37 | +
|
| 38 | + These tags are named after Python packages/modules (e.g., :mod:`~sage.symbolic`), |
| 39 | + not distribution packages (``sagemath-symbolics``). |
| 40 | +
|
| 41 | + This is motivated by a separation of concerns: The author of a module that depends |
| 42 | + on some functionality provided by a Python module usually already knows the |
| 43 | + name of the Python module, so we do not want to force the author to also |
| 44 | + know about the distribution package that provides the Python module. |
| 45 | +
|
| 46 | + Instead, we associate distribution packages to Python modules in |
| 47 | + :mod:`sage.features.sagemath` via the ``spkg`` parameter of :class:`PythonModule``. |
| 48 | + """ |
| 49 | + if sage__combinat().is_present(): |
| 50 | + yield 'sage.combinat' |
| 51 | + if sage__graphs().is_present(): |
| 52 | + yield 'sage.graphs' |
| 53 | + if sage__rings__real_double().is_present(): |
| 54 | + yield 'sage.rings.real_double' |
| 55 | + if sage__symbolic().is_present(): |
| 56 | + yield 'sage.symbolic' |
0 commit comments