Skip to content

Commit

Permalink
sagemathgh-39424: Fix bug with sage_getfile in meson editable install
Browse files Browse the repository at this point in the history
    
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
  • Loading branch information
Release Manager committed Feb 9, 2025
2 parents 17983c9 + 2a3aee0 commit 7821f54
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 7821f54

Please sign in to comment.