@@ -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