Skip to content

Commit

Permalink
Fix bug with sage_getfile in meson editable install
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Feb 1, 2025
1 parent dc99dc8 commit 2a3aee0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ def _extract_embedded_position(docstring):
from sage.misc.temporary_file import spyx_tmp
if raw_filename.startswith('sage/'):
import sage
try_filenames = [os.path.join(directory, raw_filename[5:])
from sage.env import SAGE_SRC
try_filenames = [os.path.join(directory, raw_filename.removeprefix('sage/'))
for directory in sage.__path__]
try_filenames.append(os.path.join(SAGE_SRC, raw_filename)) # meson editable install
else:
try_filenames = []
try_filenames.append(
Expand Down Expand Up @@ -1286,6 +1288,15 @@ def sage_getfile(obj):
sage: sage_getfile(P) # needs sage.libs.singular
'...sage/rings/polynomial/multi_polynomial_libsingular...'
Another bug with editable meson install::
sage: P.<x,y> = QQ[]
sage: I = P * [x,y]
sage: path = sage_getfile(I.groebner_basis); path
'.../sage/rings/qqbar_decorators.py'
sage: path == sage_getfile(sage.rings.qqbar_decorators)
True
A problem fixed in :issue:`16309`::
sage: cython( # needs sage.misc.cython
Expand Down Expand Up @@ -1325,7 +1336,7 @@ def sage_getfile(obj):
return ''
for suffix in import_machinery.EXTENSION_SUFFIXES:
if sourcefile.endswith(suffix):
return sourcefile[:-len(suffix)]+os.path.extsep+'pyx'
return sourcefile.removesuffix(suffix)+os.path.extsep+'pyx'
return sourcefile


Expand Down

0 comments on commit 2a3aee0

Please sign in to comment.