diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py index 75a925895c5..2001f793a2f 100644 --- a/src/sage/features/sagemath.py +++ b/src/sage/features/sagemath.py @@ -43,6 +43,31 @@ from .join_feature import JoinFeature +class SAGE_SRC(StaticFile): + r""" + A :class:`~sage.features.Feature` which describes the presence of the + monolithic source tree of the Sage library. + + """ + def __init__(self): + r""" + TESTS:: + + sage: from sage.features.sagemath import SAGE_SRC + sage: isinstance(SAGE_SRC(), SAGE_SRC) + True + """ + from sage.env import SAGE_SRC + # We check the file bin/sage-src-env-config.in, which by design is: + # - never installed, + # - not included in the sagemath-standard sdist, + # - included only in one modularized sdist, of pkgs/sage-conf_pypi, + # where it appears in a subdirectory (sage_root/src/bin/) + StaticFile.__init__(self, 'SAGE_SRC', + filename='bin/sage-src-env-config.in', + search_path=(SAGE_SRC,) if SAGE_SRC else ()) + + class sagemath_doc_html(StaticFile): r""" A :class:`~sage.features.Feature` which describes the presence of the documentation @@ -1095,7 +1120,8 @@ def all_features(): sage: list(all_features()) [...Feature('sage.combinat'), ...] """ - return [sagemath_doc_html(), + return [SAGE_SRC(), + sagemath_doc_html(), sage__combinat(), sage__geometry__polyhedron(), sage__graphs(), diff --git a/src/sage/misc/package_dir.py b/src/sage/misc/package_dir.py index 16c78d18462..adfb62331fb 100644 --- a/src/sage/misc/package_dir.py +++ b/src/sage/misc/package_dir.py @@ -111,6 +111,7 @@ def read_distribution(src_file): EXAMPLES:: + sage: # needs SAGE_SRC sage: from sage.env import SAGE_SRC sage: from sage.misc.package_dir import read_distribution sage: read_distribution(os.path.join(SAGE_SRC, 'sage', 'graphs', 'graph_decompositions', 'tdlib.pyx')) diff --git a/src/sage/misc/replace_dot_all.py b/src/sage/misc/replace_dot_all.py index 117b7f6892b..aa1b1ff593d 100644 --- a/src/sage/misc/replace_dot_all.py +++ b/src/sage/misc/replace_dot_all.py @@ -111,8 +111,9 @@ def find_replacements(location, package_regex=None, verbose=False): EXAMPLES:: + sage: # needs SAGE_SRC sage: from sage.misc.replace_dot_all import * - sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py') + sage: location = os.path.join(sage.env.SAGE_SRC, 'sage', 'plot', 'arc.py') sage: find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True) [[..., ..., 'from sage.plot.graphics import Graphics']] """ @@ -295,8 +296,9 @@ def process_line(location, line, replacements, row_index, verbose=False): Replacing the first line which needs a replacement in the source file with filepath ``src/sage/plot/arc.py``:: + sage: # needs SAGE_SRC sage: from sage.misc.replace_dot_all import * - sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py') + sage: location = os.path.join(sage.env.SAGE_SRC, 'sage', 'plot', 'arc.py') sage: replacements = find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True); replacements [[477, 24, 'from sage.plot.graphics import Graphics']] sage: with open(location, "r") as file: @@ -401,6 +403,7 @@ def walkdir_replace_dot_all(dir, file_regex=r'.*[.](py|pyx|pxi)$', package_regex EXAMPLES:: + sage: # needs SAGE_SRC sage: from sage.misc.replace_dot_all import * sage: walkdir_replace_dot_all(os.path.join(sage.env.SAGE_SRC, 'sage')) # not tested """ diff --git a/src/sage_setup/clean.py b/src/sage_setup/clean.py index e9c81c9ed1a..1b00f211d75 100644 --- a/src/sage_setup/clean.py +++ b/src/sage_setup/clean.py @@ -80,6 +80,7 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module course. We check that when the doctest is being run, that is, after installation, there are no stale files:: + sage: # needs SAGE_SRC sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_ROOT sage: from sage_setup.find import _cythonized_dir sage: cythonized_dir = _cythonized_dir(SAGE_SRC) @@ -98,6 +99,7 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module TODO: Also check extension modules:: + sage: # needs SAGE_SRC sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files) sage: from importlib.machinery import EXTENSION_SUFFIXES sage: skip_extensions = tuple(EXTENSION_SUFFIXES) diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py index 61d91abc2eb..69bad9a3ebf 100644 --- a/src/sage_setup/find.py +++ b/src/sage_setup/find.py @@ -1,3 +1,4 @@ +# sage.doctest: needs SAGE_SRC """ Recursive Directory Contents """