diff --git a/mypy/main.py b/mypy/main.py index 9416536f73b75..f52e32220f2e0 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -14,7 +14,10 @@ from mypy import defaults from mypy import state from mypy import util -from mypy.modulefinder import BuildSource, FindModuleCache, mypy_path, SearchPaths +from mypy.modulefinder import ( + BuildSource, FindModuleCache, SearchPaths, + get_site_packages_dirs, mypy_path +) from mypy.find_sources import create_source_list, InvalidSourceList from mypy.fscache import FileSystemCache from mypy.errors import CompileError @@ -921,7 +924,16 @@ def set_strict_flags() -> None: # Set target. if special_opts.modules + special_opts.packages: options.build_type = BuildType.MODULE - search_paths = SearchPaths((os.getcwd(),), tuple(mypy_path() + options.mypy_path), (), ()) + # NB: duplicated logic from compute_search_paths + if options.python_executable is None: + egg_dirs = [] # type: List[str] + site_packages = [] # type: List[str] + else: + egg_dirs, site_packages = get_site_packages_dirs(options.python_executable) + search_paths = SearchPaths((os.getcwd(),), + tuple(mypy_path() + options.mypy_path), + tuple(egg_dirs + site_packages), + ()) targets = [] # TODO: use the same cache that the BuildManager will cache = FindModuleCache(search_paths, fscache, options, special_opts.packages)