Skip to content

Commit 0a75254

Browse files
author
Release Manager
committed
gh-37650: src/sage/features/sagemath.py: Add feature SAGE_SRC <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> This feature is for conditionalizing some doctests. Fixes doctest failure reported in #37645. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37650 Reported by: Matthias Köppe Reviewer(s): François Bissey, Gonzalo Tornaría, Matthias Köppe
2 parents 721fc79 + 576d8bf commit 0a75254

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

src/sage/features/sagemath.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,31 @@
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+
# We check the file bin/sage-src-env-config.in, which by design is:
62+
# - never installed,
63+
# - not included in the sagemath-standard sdist,
64+
# - included only in one modularized sdist, of pkgs/sage-conf_pypi,
65+
# where it appears in a subdirectory (sage_root/src/bin/)
66+
StaticFile.__init__(self, 'SAGE_SRC',
67+
filename='bin/sage-src-env-config.in',
68+
search_path=(SAGE_SRC,) if SAGE_SRC else ())
69+
70+
4671
class sagemath_doc_html(StaticFile):
4772
r"""
4873
A :class:`~sage.features.Feature` which describes the presence of the documentation
@@ -1095,7 +1120,8 @@ def all_features():
10951120
sage: list(all_features())
10961121
[...Feature('sage.combinat'), ...]
10971122
"""
1098-
return [sagemath_doc_html(),
1123+
return [SAGE_SRC(),
1124+
sagemath_doc_html(),
10991125
sage__combinat(),
11001126
sage__geometry__polyhedron(),
11011127
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)