Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
src/sage/misc/cachefunc.pyx: Remove use of SAGE_LIB
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed May 8, 2022
1 parent b41da0c commit 877fe16
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/sage/misc/cachefunc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -875,17 +875,20 @@ cdef class CachedFunction(object):
if not doc or _extract_embedded_position(doc) is None:
try:
sourcelines = sage_getsourcelines(f)
from sage.env import SAGE_SRC, SAGE_LIB
filename = sage_getfile(f)

#it would be nice if we could be sure that SAGE_SRC and
#SAGE_LIB were already normalized (e.g. not end in a slash)
S=normpath(SAGE_SRC)
L=normpath(SAGE_LIB)
if commonprefix([filename,S]) == S:
filename = relpath(filename,S)
elif commonprefix([filename,L]) == L:
filename = relpath(filename,L)
def directories():
from sage.env import SAGE_SRC
if SAGE_SRC:
yield normpath(os.path.join(SAGE_SRC, 'sage'))
import sage
yield from sage.__path__

for directory in directories():
if commonprefix([filename, directory]) == directory:
filename = os.path.join('sage', relpath(filename, directory))
break

#this is a rather expensive way of getting the line number, because
#retrieving the source requires reading the source file and in many
#cases this is not required (in cython it's embedded in the docstring,
Expand Down

0 comments on commit 877fe16

Please sign in to comment.