MCPcopy Create free account
hub / github.com/numpy/numpy / rel_path

Function rel_path

numpy/distutils/misc_util.py:134–146  ·  view source on GitHub ↗

Return path relative to parent_path.

(path, parent_path)

Source from the content-addressed store, hash-verified

132 return os.path.join(*split)
133
134def rel_path(path, parent_path):
135 """Return path relative to parent_path."""
136 # Use realpath to avoid issues with symlinked dirs (see gh-7707)
137 pd = os.path.realpath(os.path.abspath(parent_path))
138 apath = os.path.realpath(os.path.abspath(path))
139 if len(apath) < len(pd):
140 return path
141 if apath == pd:
142 return ''
143 if pd == apath[:len(pd)]:
144 assert apath[len(pd)] in [os.sep], repr((path, apath[len(pd)]))
145 path = apath[len(pd)+1:]
146 return path
147
148def get_path_from_frame(frame, parent_path=None):
149 """Return path of the module given a frame object from the call stack.

Callers 3

get_path_from_frameFunction · 0.85
add_data_dirMethod · 0.85

Calls 1

abspathMethod · 0.45

Tested by

no test coverage detected