Skip to content

Mention pip in Quick start. #492

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 4 commits into from
Nov 24, 2014
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ For other Linux flavors, OS X and Windows, packages are available at
Quick start
-----------

If you have git, first clone the mypy git repository:
Mypy can be installed from pip:

$ pip install mypy-lang

If you want to contribute and have git,
first clone the mypy git repository:

$ git clone https://github.com/JukkaL/mypy.git

Expand Down
12 changes: 9 additions & 3 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def build(program_path: str,
pyversion: int = 3,
custom_typing_module: str = None,
html_report_dir: str = None,
flags: List[str] = None) -> BuildResult:
flags: List[str] = None,
python_path: bool = False) -> BuildResult:
"""Build a mypy program.

A single call to build performs parsing, semantic analysis and optionally
Expand Down Expand Up @@ -122,7 +123,7 @@ def build(program_path: str,
data_dir = default_data_dir(bin_dir)

# Determine the default module search path.
lib_path = default_lib_path(data_dir, target, pyversion)
lib_path = default_lib_path(data_dir, target, pyversion, python_path)

if TEST_BUILTINS in flags:
# Use stub builtins (to speed up test cases and to make them easier to
Expand Down Expand Up @@ -191,7 +192,8 @@ def default_data_dir(bin_dir: str) -> str:
raise RuntimeError("Broken installation: can't determine base dir")


def default_lib_path(data_dir: str, target: int, pyversion: int) -> List[str]:
def default_lib_path(data_dir: str, target: int, pyversion: int,
python_path:bool) -> List[str]:
"""Return default standard library search paths."""
# IDEA: Make this more portable.
path = List[str]()
Expand All @@ -218,6 +220,10 @@ def default_lib_path(data_dir: str, target: int, pyversion: int) -> List[str]:
if sys.platform != 'win32':
path.append('/usr/local/lib/mypy')

# Contents of Python's sys.path go last, to prefer the stubs
if python_path:
path.extend(sys.path)

return path


Expand Down
12 changes: 11 additions & 1 deletion scripts/mypy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Options:
self.pyversion = 3
self.custom_typing_module = None # type: str
self.html_report_dir = None # type: str
self.python_path = False


def main() -> None:
Expand Down Expand Up @@ -73,7 +74,8 @@ def type_check_only(path: str, module: str, bin_dir: str, options: Options) -> N
pyversion=options.pyversion,
custom_typing_module=options.custom_typing_module,
html_report_dir=options.html_report_dir,
flags=options.build_flags)
flags=options.build_flags,
python_path=options.python_path)


def process_options(args: List[str]) -> Tuple[str, str, Options]:
Expand Down Expand Up @@ -112,6 +114,9 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]:
options.html_report_dir = args[1]
options.build_flags.append('html-report')
args = args[2:]
elif args[0] == '--use-python-path':
options.python_path = True
args = args[1:]
else:
usage('Unknown option: {}'.format(args[0]))

Expand All @@ -124,6 +129,10 @@ def process_options(args: List[str]) -> Tuple[str, str, Options]:
if args[1:]:
usage('Extra argument: {}'.format(args[1]))

if options.python_path and options.pyversion == 2:
usage('--py2 specified, '
'but --use-python-path will search in sys.path of Python 3')

return args[0], None, options


Expand All @@ -143,6 +152,7 @@ Optional arguments:
--html-report dir generate a HTML report of type precision under dir/
-m mod type check module
--verbose more verbose messages
--use-python-path search for modules in sys.path of running Python

Environment variables:
MYPYPATH additional module search path
Expand Down