Skip to content

Fix finding typeshed user install on Windows #3991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,13 @@ def default_data_dir(bin_dir: Optional[str]) -> str:
# or .../blah/lib64/python3.N/dist-packages/mypy/build.py (Gentoo)
# or .../blah/lib/site-packages/mypy/build.py (Windows)
# blah may be a virtualenv or /usr/local. We want .../blah/lib/mypy.
# On Windows, if the install is .../python/PythonXY/site-packages, we want
# .../python/lib/mypy
lib = parent
for i in range(2):
lib = os.path.dirname(lib)
if os.path.basename(lib) in ('lib', 'lib32', 'lib64'):
if os.path.basename(lib) in ('lib', 'lib32', 'lib64') \
or os.path.basename(lib).startswith('python'):
return os.path.join(os.path.dirname(lib), 'lib/mypy')
subdir = os.path.join(parent, 'lib', 'mypy')
if os.path.isdir(subdir):
Expand Down Expand Up @@ -299,9 +302,10 @@ def default_lib_path(data_dir: str,
if sys.platform != 'win32':
path.append('/usr/local/lib/mypy')
if not path:
print("Could not resolve typeshed subdirectories. If you are using MyPy"
"from source, you need to run \"git submodule --init update\"."
"Otherwise your MyPy install is broken.", file=sys.stderr)
print("Could not resolve typeshed subdirectories. If you are using mypy\n"
"from source, you need to run \"git submodule --init update\".\n"
"Otherwise your mypy install is broken.\nPython executable is located at "
"{0}.\nMypy located at {1}".format(sys.executable, data_dir), file=sys.stderr)
sys.exit(1)
return path

Expand Down