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

Function appendpath

numpy/distutils/misc_util.py:2307–2326  ·  view source on GitHub ↗
(prefix, path)

Source from the content-addressed store, hash-verified

2305 d[k] = v
2306
2307def appendpath(prefix, path):
2308 if os.path.sep != '/':
2309 prefix = prefix.replace('/', os.path.sep)
2310 path = path.replace('/', os.path.sep)
2311 drive = ''
2312 if os.path.isabs(path):
2313 drive = os.path.splitdrive(prefix)[0]
2314 absprefix = os.path.splitdrive(os.path.abspath(prefix))[1]
2315 pathdrive, path = os.path.splitdrive(path)
2316 d = os.path.commonprefix([absprefix, path])
2317 if os.path.join(absprefix[:len(d)], absprefix[len(d):]) != absprefix \
2318 or os.path.join(path[:len(d)], path[len(d):]) != path:
2319 # Handle invalid paths
2320 d = os.path.dirname(d)
2321 subpath = path[len(d):]
2322 if os.path.isabs(subpath):
2323 subpath = subpath[1:]
2324 else:
2325 subpath = path
2326 return os.path.normpath(njoin(drive + prefix, subpath))
2327
2328def generate_config_py(target):
2329 """Generate config.py file containing system_info information

Callers 6

template_sourcesMethod · 0.90
f2py_sourcesMethod · 0.90
swig_sourcesMethod · 0.90
test_1Method · 0.90
test_2Method · 0.90
test_3Method · 0.90

Calls 4

njoinFunction · 0.85
replaceMethod · 0.80
abspathMethod · 0.45
joinMethod · 0.45

Tested by 3

test_1Method · 0.72
test_2Method · 0.72
test_3Method · 0.72