Skip to content

Commit 7cd5a23

Browse files
author
Matthias Koeppe
committed
src/sage/features/sagemath.py: Add feature SAGE_SRC
1 parent c4363fc commit 7cd5a23

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

src/sage/features/sagemath.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@
4343
from .join_feature import JoinFeature
4444

4545

46+
class SAGE_SRC(StaticFile):
47+
r"""
48+
A :class:`~sage.features.Feature` which describes the presence of the
49+
monolithic source tree of the Sage library.
50+
51+
"""
52+
def __init__(self):
53+
r"""
54+
TESTS::
55+
56+
sage: from sage.features.sagemath import SAGE_SRC
57+
sage: isinstance(SAGE_SRC(), SAGE_SRC)
58+
True
59+
"""
60+
from sage.env import SAGE_SRC
61+
StaticFile.__init__(self, 'SAGE_SRC',
62+
filename='VERSION.txt', # a file that is never installed
63+
search_path=(SAGE_SRC,) if SAGE_SRC else ())
64+
65+
4666
class sagemath_doc_html(StaticFile):
4767
r"""
4868
A :class:`~sage.features.Feature` which describes the presence of the documentation
@@ -1095,7 +1115,8 @@ def all_features():
10951115
sage: list(all_features())
10961116
[...Feature('sage.combinat'), ...]
10971117
"""
1098-
return [sagemath_doc_html(),
1118+
return [SAGE_SRC(),
1119+
sagemath_doc_html(),
10991120
sage__combinat(),
11001121
sage__geometry__polyhedron(),
11011122
sage__graphs(),

src/sage/misc/package_dir.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def read_distribution(src_file):
111111
112112
EXAMPLES::
113113
114+
sage: # needs SAGE_SRC
114115
sage: from sage.env import SAGE_SRC
115116
sage: from sage.misc.package_dir import read_distribution
116117
sage: read_distribution(os.path.join(SAGE_SRC, 'sage', 'graphs', 'graph_decompositions', 'tdlib.pyx'))

src/sage/misc/replace_dot_all.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ def find_replacements(location, package_regex=None, verbose=False):
111111
112112
EXAMPLES::
113113
114+
sage: # needs SAGE_SRC
114115
sage: from sage.misc.replace_dot_all import *
115-
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py')
116+
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage', 'plot', 'arc.py')
116117
sage: find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True)
117118
[[..., ..., 'from sage.plot.graphics import Graphics']]
118119
"""
@@ -295,8 +296,9 @@ def process_line(location, line, replacements, row_index, verbose=False):
295296
296297
Replacing the first line which needs a replacement in the source file with filepath ``src/sage/plot/arc.py``::
297298
299+
sage: # needs SAGE_SRC
298300
sage: from sage.misc.replace_dot_all import *
299-
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage/plot/arc.py')
301+
sage: location = os.path.join(sage.env.SAGE_SRC, 'sage', 'plot', 'arc.py')
300302
sage: replacements = find_replacements(location, package_regex='sage[.]plot[.]all', verbose=True); replacements
301303
[[477, 24, 'from sage.plot.graphics import Graphics']]
302304
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
401403
402404
EXAMPLES::
403405
406+
sage: # needs SAGE_SRC
404407
sage: from sage.misc.replace_dot_all import *
405408
sage: walkdir_replace_dot_all(os.path.join(sage.env.SAGE_SRC, 'sage')) # not tested
406409
"""

src/sage_setup/clean.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module
8080
course. We check that when the doctest is being run, that is,
8181
after installation, there are no stale files::
8282
83+
sage: # needs SAGE_SRC
8384
sage: from sage.env import SAGE_SRC, SAGE_LIB, SAGE_ROOT
8485
sage: from sage_setup.find import _cythonized_dir
8586
sage: cythonized_dir = _cythonized_dir(SAGE_SRC)
@@ -98,6 +99,7 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module
9899
99100
TODO: Also check extension modules::
100101
102+
sage: # needs SAGE_SRC
101103
sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [], extra_files)
102104
sage: from importlib.machinery import EXTENSION_SUFFIXES
103105
sage: skip_extensions = tuple(EXTENSION_SUFFIXES)

src/sage_setup/find.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# sage.doctest: needs SAGE_SRC
12
"""
23
Recursive Directory Contents
34
"""

0 commit comments

Comments
 (0)