Skip to content

Commit f181130

Browse files
committed
extract default pkg paths in function
1 parent 20ae3b5 commit f181130

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

mypy/build.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,16 @@ def mypy_path() -> List[str]:
245245
return path_env.split(os.pathsep)
246246

247247

248+
def get_pkg_locations():
249+
# The paths are based on https://docs.python.org/3/install
250+
yield site.USER_BASE # default user pkg dir
251+
yield sys.prefix # default system pkg dir
252+
253+
if sys.platform != 'win32':
254+
yield '/usr'
255+
yield '/usr/local'
256+
257+
248258
def default_lib_path(data_dir: str, pyversion: Tuple[int, int]) -> List[str]:
249259
"""Return default standard library search paths."""
250260
# IDEA: Make this more portable.
@@ -263,11 +273,9 @@ def default_lib_path(data_dir: str, pyversion: Tuple[int, int]) -> List[str]:
263273
for v in versions + [str(pyversion[0]), '2and3']:
264274
# Add package installed annotations.
265275
# The idea is to implement the example in PEP 484, where the annotations
266-
# are installed under shared/typehints/python. We here search for the
267-
# user installation first, then system wide and add it if needed.
268-
# The paths are based on https://docs.python.org/3/install
276+
# are installed under shared/typehints/python.
269277
# TODO it would be nicer to find typehints directly via pkg_resources
270-
for pkginstalldir in (site.USER_BASE, sys.prefix):
278+
for pkginstalldir in get_pkg_locations():
271279
subdir = os.path.join('shared', 'typehints', 'python' + v)
272280
pkgstubdir = os.path.join(pkginstalldir, subdir)
273281
if os.path.isdir(pkgstubdir):

0 commit comments

Comments
 (0)