Skip to content

Commit 7821f54

Browse files
author
Release Manager
committed
sagemathgh-39424: Fix bug with sage_getfile in meson editable install Previously, the following test fails with meson editable install ``` 2025-01-28T04:27:13.4765580Z File "src/sage/misc/cachefunc.pyx", line 881, in sage.misc.cachefunc.CachedFunction._instancedoc_ 2025-01-28T04:27:13.4766297Z Failed example: 2025-01-28T04:27:13.4766651Z os.path.exists(sage_getfile(I.groebner_basis)) 2025-01-28T04:27:13.4767084Z Expected: 2025-01-28T04:27:13.4767330Z True 2025-01-28T04:27:13.4767571Z Got: 2025-01-28T04:27:13.4767808Z False ``` See https://github.com/sagemath/sage/actions/runs/13003203795/job/362655 39648 . ### 📝 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. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. (can't really test, but see sagemath#39369) - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39424 Reported by: user202729 Reviewer(s): Tobias Diez
2 parents 17983c9 + 2a3aee0 commit 7821f54

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/sage/misc/sageinspect.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ def _extract_embedded_position(docstring):
276276
from sage.misc.temporary_file import spyx_tmp
277277
if raw_filename.startswith('sage/'):
278278
import sage
279-
try_filenames = [os.path.join(directory, raw_filename[5:])
279+
from sage.env import SAGE_SRC
280+
try_filenames = [os.path.join(directory, raw_filename.removeprefix('sage/'))
280281
for directory in sage.__path__]
282+
try_filenames.append(os.path.join(SAGE_SRC, raw_filename)) # meson editable install
281283
else:
282284
try_filenames = []
283285
try_filenames.append(
@@ -1286,6 +1288,15 @@ def sage_getfile(obj):
12861288
sage: sage_getfile(P) # needs sage.libs.singular
12871289
'...sage/rings/polynomial/multi_polynomial_libsingular...'
12881290
1291+
Another bug with editable meson install::
1292+
1293+
sage: P.<x,y> = QQ[]
1294+
sage: I = P * [x,y]
1295+
sage: path = sage_getfile(I.groebner_basis); path
1296+
'.../sage/rings/qqbar_decorators.py'
1297+
sage: path == sage_getfile(sage.rings.qqbar_decorators)
1298+
True
1299+
12891300
A problem fixed in :issue:`16309`::
12901301
12911302
sage: cython( # needs sage.misc.cython
@@ -1325,7 +1336,7 @@ def sage_getfile(obj):
13251336
return ''
13261337
for suffix in import_machinery.EXTENSION_SUFFIXES:
13271338
if sourcefile.endswith(suffix):
1328-
return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
1339+
return sourcefile.removesuffix(suffix)+os.path.extsep+'pyx'
13291340
return sourcefile
13301341

13311342

0 commit comments

Comments
 (0)