MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _get_library_dir

Function _get_library_dir

pydevd_file_utils.py:75–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73
74
75def _get_library_dir():
76 library_dir = None
77 try:
78 import sysconfig
79
80 library_dir = sysconfig.get_path("purelib")
81 except ImportError:
82 pass # i.e.: Only 2.7 onwards
83
84 if library_dir is None or not os_path_exists(library_dir):
85 for path in sys.path:
86 if os_path_exists(path) and os.path.basename(path) == "site-packages":
87 library_dir = path
88 break
89
90 if library_dir is None or not os_path_exists(library_dir):
91 if hasattr(os, "__file__"):
92 # "os" is a frozen import an thus "os.__file__" is not always set.
93 # See https://github.com/python/cpython/pull/28656
94 library_dir = os.path.dirname(os.__file__)
95 else:
96 # "threading" is not a frozen import an thus "threading.__file__" is always set.
97 import threading
98 library_dir = os.path.dirname(threading.__file__)
99
100 return library_dir
101
102
103# Note: we can't call sysconfig.get_path from _apply_func_and_normalize_case (it deadlocks on Python 2.7) so, we

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected