From 7dec9a37757e0603ecac9f69791c1885be6d0187 Mon Sep 17 00:00:00 2001 From: Marcell Vazquez-Chanlatte Date: Sun, 10 Aug 2014 14:46:57 -0700 Subject: [PATCH 1/4] made access to data like vm, stubs, and lib portable --- mypy/build.py | 59 +++++-------------- {lib => mypy/lib}/builtins.py | 0 {stubs => mypy/stubs}/2.7/__future__.py | 0 {stubs => mypy/stubs}/2.7/abc.py | 0 {stubs => mypy/stubs}/2.7/builtins.py | 0 {stubs => mypy/stubs}/2.7/io.py | 0 {stubs => mypy/stubs}/2.7/json.py | 0 {stubs => mypy/stubs}/2.7/re.py | 0 {stubs => mypy/stubs}/2.7/simplejson.py | 0 {stubs => mypy/stubs}/2.7/sys.py | 0 {stubs => mypy/stubs}/2.7/typing.py | 0 {stubs => mypy/stubs}/3.2/__future__.py | 0 {stubs => mypy/stubs}/3.2/_dummy_thread.py | 0 {stubs => mypy/stubs}/3.2/_posixsubprocess.py | 0 {stubs => mypy/stubs}/3.2/_random.py | 0 {stubs => mypy/stubs}/3.2/_subprocess.py | 0 {stubs => mypy/stubs}/3.2/_thread.py | 0 {stubs => mypy/stubs}/3.2/abc.py | 0 {stubs => mypy/stubs}/3.2/array.py | 0 {stubs => mypy/stubs}/3.2/atexit.py | 0 {stubs => mypy/stubs}/3.2/base64.py | 0 {stubs => mypy/stubs}/3.2/binascii.py | 0 {stubs => mypy/stubs}/3.2/builtins.py | 0 {stubs => mypy/stubs}/3.2/bz2.py | 0 {stubs => mypy/stubs}/3.2/calendar.py | 0 {stubs => mypy/stubs}/3.2/cgi.py | 0 {stubs => mypy/stubs}/3.2/codecs.py | 0 {stubs => mypy/stubs}/3.2/collections.py | 0 {stubs => mypy/stubs}/3.2/contextlib.py | 0 {stubs => mypy/stubs}/3.2/copy.py | 0 .../stubs}/3.2/distutils/__init__.py | 0 {stubs => mypy/stubs}/3.2/distutils/errors.py | 0 {stubs => mypy/stubs}/3.2/distutils/spawn.py | 0 {stubs => mypy/stubs}/3.2/doctest.py | 0 .../stubs}/3.2/docutils/__init__.py | 0 .../stubs}/3.2/docutils/examples.py | 0 {stubs => mypy/stubs}/3.2/docutils/nodes.py | 0 .../stubs}/3.2/docutils/parsers/__init__.py | 0 .../3.2/docutils/parsers/rst/__init__.py | 0 .../stubs}/3.2/docutils/parsers/rst/nodes.py | 0 .../stubs}/3.2/docutils/parsers/rst/roles.py | 0 .../stubs}/3.2/docutils/parsers/rst/states.py | 0 {stubs => mypy/stubs}/3.2/encodings.py | 0 {stubs => mypy/stubs}/3.2/errno.py | 0 {stubs => mypy/stubs}/3.2/fcntl.py | 0 {stubs => mypy/stubs}/3.2/fnmatch.py | 0 {stubs => mypy/stubs}/3.2/functools.py | 0 {stubs => mypy/stubs}/3.2/gc.py | 0 {stubs => mypy/stubs}/3.2/getopt.py | 0 {stubs => mypy/stubs}/3.2/glob.py | 0 {stubs => mypy/stubs}/3.2/grp.py | 0 {stubs => mypy/stubs}/3.2/hashlib.py | 0 {stubs => mypy/stubs}/3.2/heapq.py | 0 {stubs => mypy/stubs}/3.2/imp.py | 0 {stubs => mypy/stubs}/3.2/importlib.py | 0 {stubs => mypy/stubs}/3.2/inspect.py | 0 {stubs => mypy/stubs}/3.2/io.py | 0 {stubs => mypy/stubs}/3.2/itertools.py | 0 {stubs => mypy/stubs}/3.2/json.py | 0 {stubs => mypy/stubs}/3.2/locale.py | 0 {stubs => mypy/stubs}/3.2/logging/__init__.py | 0 {stubs => mypy/stubs}/3.2/logging/handlers.py | 0 {stubs => mypy/stubs}/3.2/math.py | 0 {stubs => mypy/stubs}/3.2/msvcrt.py | 0 {stubs => mypy/stubs}/3.2/operator.py | 0 {stubs => mypy/stubs}/3.2/os/__init__.py | 0 {stubs => mypy/stubs}/3.2/os/path.py | 0 {stubs => mypy/stubs}/3.2/pickle.py | 0 {stubs => mypy/stubs}/3.2/platform.py | 0 {stubs => mypy/stubs}/3.2/posix.py | 0 {stubs => mypy/stubs}/3.2/posixpath.py | 0 {stubs => mypy/stubs}/3.2/pprint.py | 0 {stubs => mypy/stubs}/3.2/pwd.py | 0 {stubs => mypy/stubs}/3.2/random.py | 0 {stubs => mypy/stubs}/3.2/re.py | 0 {stubs => mypy/stubs}/3.2/resource.py | 0 {stubs => mypy/stubs}/3.2/select.py | 0 {stubs => mypy/stubs}/3.2/shlex.py | 0 {stubs => mypy/stubs}/3.2/shutil.py | 0 {stubs => mypy/stubs}/3.2/signal.py | 0 {stubs => mypy/stubs}/3.2/socket.py | 0 {stubs => mypy/stubs}/3.2/stat.py | 0 {stubs => mypy/stubs}/3.2/string.py | 0 {stubs => mypy/stubs}/3.2/struct.py | 0 {stubs => mypy/stubs}/3.2/subprocess.py | 0 {stubs => mypy/stubs}/3.2/sys.py | 0 {stubs => mypy/stubs}/3.2/sysconfig.py | 0 {stubs => mypy/stubs}/3.2/tarfile.py | 0 {stubs => mypy/stubs}/3.2/tempfile.py | 0 {stubs => mypy/stubs}/3.2/threading.py | 0 {stubs => mypy/stubs}/3.2/time.py | 0 {stubs => mypy/stubs}/3.2/traceback.py | 0 {stubs => mypy/stubs}/3.2/types.py | 0 {stubs => mypy/stubs}/3.2/typing.py | 0 {stubs => mypy/stubs}/3.2/unicodedata.py | 0 {stubs => mypy/stubs}/3.2/unittest.py | 0 {stubs => mypy/stubs}/3.2/urllib/__init__.py | 0 {stubs => mypy/stubs}/3.2/urllib/parse.py | 0 {stubs => mypy/stubs}/3.2/urllib/request.py | 0 {stubs => mypy/stubs}/3.2/warnings.py | 0 {stubs => mypy/stubs}/3.2/weakref.py | 0 {stubs => mypy/stubs}/3.2/zipfile.py | 0 {stubs => mypy/stubs}/3.2/zlib.py | 0 {stubs => mypy/stubs}/3.4/asyncio/__init__.py | 0 {stubs => mypy/stubs}/3.4/asyncio/events.py | 0 {stubs => mypy/stubs}/3.4/asyncio/futures.py | 0 {stubs => mypy/stubs}/3.4/asyncio/tasks.py | 0 {vm => mypy/vm}/mypy.h | 0 {vm => mypy/vm}/runtime.c | 0 scripts/mypy | 37 ++---------- setup.py | 18 +----- stubs/3.3/do-not-remove | 0 112 files changed, 23 insertions(+), 91 deletions(-) rename {lib => mypy/lib}/builtins.py (100%) rename {stubs => mypy/stubs}/2.7/__future__.py (100%) rename {stubs => mypy/stubs}/2.7/abc.py (100%) rename {stubs => mypy/stubs}/2.7/builtins.py (100%) rename {stubs => mypy/stubs}/2.7/io.py (100%) rename {stubs => mypy/stubs}/2.7/json.py (100%) rename {stubs => mypy/stubs}/2.7/re.py (100%) rename {stubs => mypy/stubs}/2.7/simplejson.py (100%) rename {stubs => mypy/stubs}/2.7/sys.py (100%) rename {stubs => mypy/stubs}/2.7/typing.py (100%) rename {stubs => mypy/stubs}/3.2/__future__.py (100%) rename {stubs => mypy/stubs}/3.2/_dummy_thread.py (100%) rename {stubs => mypy/stubs}/3.2/_posixsubprocess.py (100%) rename {stubs => mypy/stubs}/3.2/_random.py (100%) rename {stubs => mypy/stubs}/3.2/_subprocess.py (100%) rename {stubs => mypy/stubs}/3.2/_thread.py (100%) rename {stubs => mypy/stubs}/3.2/abc.py (100%) rename {stubs => mypy/stubs}/3.2/array.py (100%) rename {stubs => mypy/stubs}/3.2/atexit.py (100%) rename {stubs => mypy/stubs}/3.2/base64.py (100%) rename {stubs => mypy/stubs}/3.2/binascii.py (100%) rename {stubs => mypy/stubs}/3.2/builtins.py (100%) rename {stubs => mypy/stubs}/3.2/bz2.py (100%) rename {stubs => mypy/stubs}/3.2/calendar.py (100%) rename {stubs => mypy/stubs}/3.2/cgi.py (100%) rename {stubs => mypy/stubs}/3.2/codecs.py (100%) rename {stubs => mypy/stubs}/3.2/collections.py (100%) rename {stubs => mypy/stubs}/3.2/contextlib.py (100%) rename {stubs => mypy/stubs}/3.2/copy.py (100%) rename {stubs => mypy/stubs}/3.2/distutils/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/distutils/errors.py (100%) rename {stubs => mypy/stubs}/3.2/distutils/spawn.py (100%) rename {stubs => mypy/stubs}/3.2/doctest.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/examples.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/nodes.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/parsers/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/parsers/rst/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/parsers/rst/nodes.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/parsers/rst/roles.py (100%) rename {stubs => mypy/stubs}/3.2/docutils/parsers/rst/states.py (100%) rename {stubs => mypy/stubs}/3.2/encodings.py (100%) rename {stubs => mypy/stubs}/3.2/errno.py (100%) rename {stubs => mypy/stubs}/3.2/fcntl.py (100%) rename {stubs => mypy/stubs}/3.2/fnmatch.py (100%) rename {stubs => mypy/stubs}/3.2/functools.py (100%) rename {stubs => mypy/stubs}/3.2/gc.py (100%) rename {stubs => mypy/stubs}/3.2/getopt.py (100%) rename {stubs => mypy/stubs}/3.2/glob.py (100%) rename {stubs => mypy/stubs}/3.2/grp.py (100%) rename {stubs => mypy/stubs}/3.2/hashlib.py (100%) rename {stubs => mypy/stubs}/3.2/heapq.py (100%) rename {stubs => mypy/stubs}/3.2/imp.py (100%) rename {stubs => mypy/stubs}/3.2/importlib.py (100%) rename {stubs => mypy/stubs}/3.2/inspect.py (100%) rename {stubs => mypy/stubs}/3.2/io.py (100%) rename {stubs => mypy/stubs}/3.2/itertools.py (100%) rename {stubs => mypy/stubs}/3.2/json.py (100%) rename {stubs => mypy/stubs}/3.2/locale.py (100%) rename {stubs => mypy/stubs}/3.2/logging/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/logging/handlers.py (100%) rename {stubs => mypy/stubs}/3.2/math.py (100%) rename {stubs => mypy/stubs}/3.2/msvcrt.py (100%) rename {stubs => mypy/stubs}/3.2/operator.py (100%) rename {stubs => mypy/stubs}/3.2/os/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/os/path.py (100%) rename {stubs => mypy/stubs}/3.2/pickle.py (100%) rename {stubs => mypy/stubs}/3.2/platform.py (100%) rename {stubs => mypy/stubs}/3.2/posix.py (100%) rename {stubs => mypy/stubs}/3.2/posixpath.py (100%) rename {stubs => mypy/stubs}/3.2/pprint.py (100%) rename {stubs => mypy/stubs}/3.2/pwd.py (100%) rename {stubs => mypy/stubs}/3.2/random.py (100%) rename {stubs => mypy/stubs}/3.2/re.py (100%) rename {stubs => mypy/stubs}/3.2/resource.py (100%) rename {stubs => mypy/stubs}/3.2/select.py (100%) rename {stubs => mypy/stubs}/3.2/shlex.py (100%) rename {stubs => mypy/stubs}/3.2/shutil.py (100%) rename {stubs => mypy/stubs}/3.2/signal.py (100%) rename {stubs => mypy/stubs}/3.2/socket.py (100%) rename {stubs => mypy/stubs}/3.2/stat.py (100%) rename {stubs => mypy/stubs}/3.2/string.py (100%) rename {stubs => mypy/stubs}/3.2/struct.py (100%) rename {stubs => mypy/stubs}/3.2/subprocess.py (100%) rename {stubs => mypy/stubs}/3.2/sys.py (100%) rename {stubs => mypy/stubs}/3.2/sysconfig.py (100%) rename {stubs => mypy/stubs}/3.2/tarfile.py (100%) rename {stubs => mypy/stubs}/3.2/tempfile.py (100%) rename {stubs => mypy/stubs}/3.2/threading.py (100%) rename {stubs => mypy/stubs}/3.2/time.py (100%) rename {stubs => mypy/stubs}/3.2/traceback.py (100%) rename {stubs => mypy/stubs}/3.2/types.py (100%) rename {stubs => mypy/stubs}/3.2/typing.py (100%) rename {stubs => mypy/stubs}/3.2/unicodedata.py (100%) rename {stubs => mypy/stubs}/3.2/unittest.py (100%) rename {stubs => mypy/stubs}/3.2/urllib/__init__.py (100%) rename {stubs => mypy/stubs}/3.2/urllib/parse.py (100%) rename {stubs => mypy/stubs}/3.2/urllib/request.py (100%) rename {stubs => mypy/stubs}/3.2/warnings.py (100%) rename {stubs => mypy/stubs}/3.2/weakref.py (100%) rename {stubs => mypy/stubs}/3.2/zipfile.py (100%) rename {stubs => mypy/stubs}/3.2/zlib.py (100%) rename {stubs => mypy/stubs}/3.4/asyncio/__init__.py (100%) rename {stubs => mypy/stubs}/3.4/asyncio/events.py (100%) rename {stubs => mypy/stubs}/3.4/asyncio/futures.py (100%) rename {stubs => mypy/stubs}/3.4/asyncio/tasks.py (100%) rename {vm => mypy/vm}/mypy.h (100%) rename {vm => mypy/vm}/runtime.c (100%) delete mode 100644 stubs/3.3/do-not-remove diff --git a/mypy/build.py b/mypy/build.py index 8679cce283c5..f533da1ba6c9 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -14,7 +14,9 @@ import shlex import subprocess import sys +from pkg_resources import resource_listdir, resource_filename from os.path import dirname, basename +from functools import partial from typing import Undefined, Dict, List, Tuple, cast, Set @@ -70,6 +72,9 @@ final_state = TYPE_CHECKED_STATE +mypy_filename = partial(resource_filename, 'mypy') + + def earlier_state(s: int, t: int) -> bool: return s < t @@ -133,10 +138,8 @@ def build(program_path: str, flags = flags or [] module = module or '__main__' - 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(target, pyversion) if TEST_BUILTINS in flags: # Use stub builtins (to speed up test cases and to make them easier to @@ -159,7 +162,7 @@ def build(program_path: str, # build in the correct order. # # Ignore current directory prefix in error messages. - manager = BuildManager(data_dir, lib_path, target, output_dir, + manager = BuildManager(lib_path, target, output_dir, pyversion=pyversion, flags=flags, ignore_prefix=os.getcwd(), custom_typing_module=custom_typing_module, @@ -181,31 +184,7 @@ def build(program_path: str, return result -def default_data_dir(bin_dir: str) -> str: - if not bin_dir: - # Default to current directory. - return '' - base = os.path.basename(bin_dir) - dir = os.path.dirname(bin_dir) - if (sys.platform == 'win32' and base.lower() == 'scripts' - and not os.path.isdir(os.path.join(dir, 'stubs'))): - # Installed, on Windows. - return os.path.join(dir, 'Lib', 'mypy') - elif base == 'scripts': - # Assume that we have a repo check out or unpacked source tarball. - return os.path.dirname(bin_dir) - elif base == 'bin': - # Installed to somewhere (can be under /usr/local or anywhere). - return os.path.join(dir, 'lib', 'mypy') - elif base == 'python3': - # Assume we installed python3 with brew on os x - return os.path.join(os.path.dirname(dir), 'lib', 'mypy') - else: - # Don't know where to find the data files! - 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(target: int, pyversion: int) -> List[str]: """Return default standard library search paths.""" # IDEA: Make this more portable. path = List[str]() @@ -214,23 +193,21 @@ def default_lib_path(data_dir: str, target: int, pyversion: int) -> List[str]: path_env = os.getenv('MYPYPATH') if path_env is not None: path[:0] = path_env.split(os.pathsep) - + if target in [ICODE, C]: # Add C back end library directory. - path.append(os.path.join(data_dir, 'lib')) + path.append(mypy_filename('lib')) else: # Add library stubs directory. By convention, they are stored in the # stubs/x.y directory of the mypy installation. version_dir = '3.2' if pyversion < 3: version_dir = '2.7' - path.append(os.path.join(data_dir, 'stubs', version_dir)) - path.append(os.path.join(data_dir, 'stubs-auto', version_dir)) + path.append(mypy_filename(os.path.join('stubs', version_dir))) #Add py3.3 and 3.4 stubs - if sys.version_info.major == 3: - versions = ['3.' + str(x) for x in range(3, sys.version_info.minor + 1)] - for v in versions: - path.append(os.path.join(data_dir, 'stubs', v)) + path.extend([mypy_filename(os.path.join('stubs', fname)) + for fname in resource_listdir('mypy', 'stubs') + if fname.startswith(str(sys.version_info.major))]) # Add fallback path that can be used if we have a broken installation. if sys.platform != 'win32': @@ -267,7 +244,6 @@ class BuildManager: build steps. Attributes: - data_dir: Mypy data directory (contains stubs) target: Build target; selects which passes to perform lib_path: Library path for looking up modules semantic_analyzer: @@ -297,8 +273,7 @@ class BuildManager: external objects. This module should not directly depend on them. """ - def __init__(self, data_dir: str, - lib_path: List[str], + def __init__(self, lib_path: List[str], target: int, output_dir: str, pyversion: int, @@ -306,7 +281,6 @@ def __init__(self, data_dir: str, ignore_prefix: str, custom_typing_module: str, html_report_dir: str) -> None: - self.data_dir = data_dir self.errors = Errors() self.errors.set_ignore_prefix(ignore_prefix) self.lib_path = lib_path @@ -559,8 +533,7 @@ def generate_c_and_compile(self, files: List[MypyFile]) -> None: if COMPILE_ONLY not in self.flags: # Generate binary file. - data_dir = self.data_dir - vm_dir = os.path.join(data_dir, 'vm') + vm_dir = mypy_filename('vm') cc = os.getenv('CC', 'gcc') cflags = shlex.split(os.getenv('CFLAGS', '-O2')) cmdline = [cc] + cflags +['-I%s' % vm_dir, diff --git a/lib/builtins.py b/mypy/lib/builtins.py similarity index 100% rename from lib/builtins.py rename to mypy/lib/builtins.py diff --git a/stubs/2.7/__future__.py b/mypy/stubs/2.7/__future__.py similarity index 100% rename from stubs/2.7/__future__.py rename to mypy/stubs/2.7/__future__.py diff --git a/stubs/2.7/abc.py b/mypy/stubs/2.7/abc.py similarity index 100% rename from stubs/2.7/abc.py rename to mypy/stubs/2.7/abc.py diff --git a/stubs/2.7/builtins.py b/mypy/stubs/2.7/builtins.py similarity index 100% rename from stubs/2.7/builtins.py rename to mypy/stubs/2.7/builtins.py diff --git a/stubs/2.7/io.py b/mypy/stubs/2.7/io.py similarity index 100% rename from stubs/2.7/io.py rename to mypy/stubs/2.7/io.py diff --git a/stubs/2.7/json.py b/mypy/stubs/2.7/json.py similarity index 100% rename from stubs/2.7/json.py rename to mypy/stubs/2.7/json.py diff --git a/stubs/2.7/re.py b/mypy/stubs/2.7/re.py similarity index 100% rename from stubs/2.7/re.py rename to mypy/stubs/2.7/re.py diff --git a/stubs/2.7/simplejson.py b/mypy/stubs/2.7/simplejson.py similarity index 100% rename from stubs/2.7/simplejson.py rename to mypy/stubs/2.7/simplejson.py diff --git a/stubs/2.7/sys.py b/mypy/stubs/2.7/sys.py similarity index 100% rename from stubs/2.7/sys.py rename to mypy/stubs/2.7/sys.py diff --git a/stubs/2.7/typing.py b/mypy/stubs/2.7/typing.py similarity index 100% rename from stubs/2.7/typing.py rename to mypy/stubs/2.7/typing.py diff --git a/stubs/3.2/__future__.py b/mypy/stubs/3.2/__future__.py similarity index 100% rename from stubs/3.2/__future__.py rename to mypy/stubs/3.2/__future__.py diff --git a/stubs/3.2/_dummy_thread.py b/mypy/stubs/3.2/_dummy_thread.py similarity index 100% rename from stubs/3.2/_dummy_thread.py rename to mypy/stubs/3.2/_dummy_thread.py diff --git a/stubs/3.2/_posixsubprocess.py b/mypy/stubs/3.2/_posixsubprocess.py similarity index 100% rename from stubs/3.2/_posixsubprocess.py rename to mypy/stubs/3.2/_posixsubprocess.py diff --git a/stubs/3.2/_random.py b/mypy/stubs/3.2/_random.py similarity index 100% rename from stubs/3.2/_random.py rename to mypy/stubs/3.2/_random.py diff --git a/stubs/3.2/_subprocess.py b/mypy/stubs/3.2/_subprocess.py similarity index 100% rename from stubs/3.2/_subprocess.py rename to mypy/stubs/3.2/_subprocess.py diff --git a/stubs/3.2/_thread.py b/mypy/stubs/3.2/_thread.py similarity index 100% rename from stubs/3.2/_thread.py rename to mypy/stubs/3.2/_thread.py diff --git a/stubs/3.2/abc.py b/mypy/stubs/3.2/abc.py similarity index 100% rename from stubs/3.2/abc.py rename to mypy/stubs/3.2/abc.py diff --git a/stubs/3.2/array.py b/mypy/stubs/3.2/array.py similarity index 100% rename from stubs/3.2/array.py rename to mypy/stubs/3.2/array.py diff --git a/stubs/3.2/atexit.py b/mypy/stubs/3.2/atexit.py similarity index 100% rename from stubs/3.2/atexit.py rename to mypy/stubs/3.2/atexit.py diff --git a/stubs/3.2/base64.py b/mypy/stubs/3.2/base64.py similarity index 100% rename from stubs/3.2/base64.py rename to mypy/stubs/3.2/base64.py diff --git a/stubs/3.2/binascii.py b/mypy/stubs/3.2/binascii.py similarity index 100% rename from stubs/3.2/binascii.py rename to mypy/stubs/3.2/binascii.py diff --git a/stubs/3.2/builtins.py b/mypy/stubs/3.2/builtins.py similarity index 100% rename from stubs/3.2/builtins.py rename to mypy/stubs/3.2/builtins.py diff --git a/stubs/3.2/bz2.py b/mypy/stubs/3.2/bz2.py similarity index 100% rename from stubs/3.2/bz2.py rename to mypy/stubs/3.2/bz2.py diff --git a/stubs/3.2/calendar.py b/mypy/stubs/3.2/calendar.py similarity index 100% rename from stubs/3.2/calendar.py rename to mypy/stubs/3.2/calendar.py diff --git a/stubs/3.2/cgi.py b/mypy/stubs/3.2/cgi.py similarity index 100% rename from stubs/3.2/cgi.py rename to mypy/stubs/3.2/cgi.py diff --git a/stubs/3.2/codecs.py b/mypy/stubs/3.2/codecs.py similarity index 100% rename from stubs/3.2/codecs.py rename to mypy/stubs/3.2/codecs.py diff --git a/stubs/3.2/collections.py b/mypy/stubs/3.2/collections.py similarity index 100% rename from stubs/3.2/collections.py rename to mypy/stubs/3.2/collections.py diff --git a/stubs/3.2/contextlib.py b/mypy/stubs/3.2/contextlib.py similarity index 100% rename from stubs/3.2/contextlib.py rename to mypy/stubs/3.2/contextlib.py diff --git a/stubs/3.2/copy.py b/mypy/stubs/3.2/copy.py similarity index 100% rename from stubs/3.2/copy.py rename to mypy/stubs/3.2/copy.py diff --git a/stubs/3.2/distutils/__init__.py b/mypy/stubs/3.2/distutils/__init__.py similarity index 100% rename from stubs/3.2/distutils/__init__.py rename to mypy/stubs/3.2/distutils/__init__.py diff --git a/stubs/3.2/distutils/errors.py b/mypy/stubs/3.2/distutils/errors.py similarity index 100% rename from stubs/3.2/distutils/errors.py rename to mypy/stubs/3.2/distutils/errors.py diff --git a/stubs/3.2/distutils/spawn.py b/mypy/stubs/3.2/distutils/spawn.py similarity index 100% rename from stubs/3.2/distutils/spawn.py rename to mypy/stubs/3.2/distutils/spawn.py diff --git a/stubs/3.2/doctest.py b/mypy/stubs/3.2/doctest.py similarity index 100% rename from stubs/3.2/doctest.py rename to mypy/stubs/3.2/doctest.py diff --git a/stubs/3.2/docutils/__init__.py b/mypy/stubs/3.2/docutils/__init__.py similarity index 100% rename from stubs/3.2/docutils/__init__.py rename to mypy/stubs/3.2/docutils/__init__.py diff --git a/stubs/3.2/docutils/examples.py b/mypy/stubs/3.2/docutils/examples.py similarity index 100% rename from stubs/3.2/docutils/examples.py rename to mypy/stubs/3.2/docutils/examples.py diff --git a/stubs/3.2/docutils/nodes.py b/mypy/stubs/3.2/docutils/nodes.py similarity index 100% rename from stubs/3.2/docutils/nodes.py rename to mypy/stubs/3.2/docutils/nodes.py diff --git a/stubs/3.2/docutils/parsers/__init__.py b/mypy/stubs/3.2/docutils/parsers/__init__.py similarity index 100% rename from stubs/3.2/docutils/parsers/__init__.py rename to mypy/stubs/3.2/docutils/parsers/__init__.py diff --git a/stubs/3.2/docutils/parsers/rst/__init__.py b/mypy/stubs/3.2/docutils/parsers/rst/__init__.py similarity index 100% rename from stubs/3.2/docutils/parsers/rst/__init__.py rename to mypy/stubs/3.2/docutils/parsers/rst/__init__.py diff --git a/stubs/3.2/docutils/parsers/rst/nodes.py b/mypy/stubs/3.2/docutils/parsers/rst/nodes.py similarity index 100% rename from stubs/3.2/docutils/parsers/rst/nodes.py rename to mypy/stubs/3.2/docutils/parsers/rst/nodes.py diff --git a/stubs/3.2/docutils/parsers/rst/roles.py b/mypy/stubs/3.2/docutils/parsers/rst/roles.py similarity index 100% rename from stubs/3.2/docutils/parsers/rst/roles.py rename to mypy/stubs/3.2/docutils/parsers/rst/roles.py diff --git a/stubs/3.2/docutils/parsers/rst/states.py b/mypy/stubs/3.2/docutils/parsers/rst/states.py similarity index 100% rename from stubs/3.2/docutils/parsers/rst/states.py rename to mypy/stubs/3.2/docutils/parsers/rst/states.py diff --git a/stubs/3.2/encodings.py b/mypy/stubs/3.2/encodings.py similarity index 100% rename from stubs/3.2/encodings.py rename to mypy/stubs/3.2/encodings.py diff --git a/stubs/3.2/errno.py b/mypy/stubs/3.2/errno.py similarity index 100% rename from stubs/3.2/errno.py rename to mypy/stubs/3.2/errno.py diff --git a/stubs/3.2/fcntl.py b/mypy/stubs/3.2/fcntl.py similarity index 100% rename from stubs/3.2/fcntl.py rename to mypy/stubs/3.2/fcntl.py diff --git a/stubs/3.2/fnmatch.py b/mypy/stubs/3.2/fnmatch.py similarity index 100% rename from stubs/3.2/fnmatch.py rename to mypy/stubs/3.2/fnmatch.py diff --git a/stubs/3.2/functools.py b/mypy/stubs/3.2/functools.py similarity index 100% rename from stubs/3.2/functools.py rename to mypy/stubs/3.2/functools.py diff --git a/stubs/3.2/gc.py b/mypy/stubs/3.2/gc.py similarity index 100% rename from stubs/3.2/gc.py rename to mypy/stubs/3.2/gc.py diff --git a/stubs/3.2/getopt.py b/mypy/stubs/3.2/getopt.py similarity index 100% rename from stubs/3.2/getopt.py rename to mypy/stubs/3.2/getopt.py diff --git a/stubs/3.2/glob.py b/mypy/stubs/3.2/glob.py similarity index 100% rename from stubs/3.2/glob.py rename to mypy/stubs/3.2/glob.py diff --git a/stubs/3.2/grp.py b/mypy/stubs/3.2/grp.py similarity index 100% rename from stubs/3.2/grp.py rename to mypy/stubs/3.2/grp.py diff --git a/stubs/3.2/hashlib.py b/mypy/stubs/3.2/hashlib.py similarity index 100% rename from stubs/3.2/hashlib.py rename to mypy/stubs/3.2/hashlib.py diff --git a/stubs/3.2/heapq.py b/mypy/stubs/3.2/heapq.py similarity index 100% rename from stubs/3.2/heapq.py rename to mypy/stubs/3.2/heapq.py diff --git a/stubs/3.2/imp.py b/mypy/stubs/3.2/imp.py similarity index 100% rename from stubs/3.2/imp.py rename to mypy/stubs/3.2/imp.py diff --git a/stubs/3.2/importlib.py b/mypy/stubs/3.2/importlib.py similarity index 100% rename from stubs/3.2/importlib.py rename to mypy/stubs/3.2/importlib.py diff --git a/stubs/3.2/inspect.py b/mypy/stubs/3.2/inspect.py similarity index 100% rename from stubs/3.2/inspect.py rename to mypy/stubs/3.2/inspect.py diff --git a/stubs/3.2/io.py b/mypy/stubs/3.2/io.py similarity index 100% rename from stubs/3.2/io.py rename to mypy/stubs/3.2/io.py diff --git a/stubs/3.2/itertools.py b/mypy/stubs/3.2/itertools.py similarity index 100% rename from stubs/3.2/itertools.py rename to mypy/stubs/3.2/itertools.py diff --git a/stubs/3.2/json.py b/mypy/stubs/3.2/json.py similarity index 100% rename from stubs/3.2/json.py rename to mypy/stubs/3.2/json.py diff --git a/stubs/3.2/locale.py b/mypy/stubs/3.2/locale.py similarity index 100% rename from stubs/3.2/locale.py rename to mypy/stubs/3.2/locale.py diff --git a/stubs/3.2/logging/__init__.py b/mypy/stubs/3.2/logging/__init__.py similarity index 100% rename from stubs/3.2/logging/__init__.py rename to mypy/stubs/3.2/logging/__init__.py diff --git a/stubs/3.2/logging/handlers.py b/mypy/stubs/3.2/logging/handlers.py similarity index 100% rename from stubs/3.2/logging/handlers.py rename to mypy/stubs/3.2/logging/handlers.py diff --git a/stubs/3.2/math.py b/mypy/stubs/3.2/math.py similarity index 100% rename from stubs/3.2/math.py rename to mypy/stubs/3.2/math.py diff --git a/stubs/3.2/msvcrt.py b/mypy/stubs/3.2/msvcrt.py similarity index 100% rename from stubs/3.2/msvcrt.py rename to mypy/stubs/3.2/msvcrt.py diff --git a/stubs/3.2/operator.py b/mypy/stubs/3.2/operator.py similarity index 100% rename from stubs/3.2/operator.py rename to mypy/stubs/3.2/operator.py diff --git a/stubs/3.2/os/__init__.py b/mypy/stubs/3.2/os/__init__.py similarity index 100% rename from stubs/3.2/os/__init__.py rename to mypy/stubs/3.2/os/__init__.py diff --git a/stubs/3.2/os/path.py b/mypy/stubs/3.2/os/path.py similarity index 100% rename from stubs/3.2/os/path.py rename to mypy/stubs/3.2/os/path.py diff --git a/stubs/3.2/pickle.py b/mypy/stubs/3.2/pickle.py similarity index 100% rename from stubs/3.2/pickle.py rename to mypy/stubs/3.2/pickle.py diff --git a/stubs/3.2/platform.py b/mypy/stubs/3.2/platform.py similarity index 100% rename from stubs/3.2/platform.py rename to mypy/stubs/3.2/platform.py diff --git a/stubs/3.2/posix.py b/mypy/stubs/3.2/posix.py similarity index 100% rename from stubs/3.2/posix.py rename to mypy/stubs/3.2/posix.py diff --git a/stubs/3.2/posixpath.py b/mypy/stubs/3.2/posixpath.py similarity index 100% rename from stubs/3.2/posixpath.py rename to mypy/stubs/3.2/posixpath.py diff --git a/stubs/3.2/pprint.py b/mypy/stubs/3.2/pprint.py similarity index 100% rename from stubs/3.2/pprint.py rename to mypy/stubs/3.2/pprint.py diff --git a/stubs/3.2/pwd.py b/mypy/stubs/3.2/pwd.py similarity index 100% rename from stubs/3.2/pwd.py rename to mypy/stubs/3.2/pwd.py diff --git a/stubs/3.2/random.py b/mypy/stubs/3.2/random.py similarity index 100% rename from stubs/3.2/random.py rename to mypy/stubs/3.2/random.py diff --git a/stubs/3.2/re.py b/mypy/stubs/3.2/re.py similarity index 100% rename from stubs/3.2/re.py rename to mypy/stubs/3.2/re.py diff --git a/stubs/3.2/resource.py b/mypy/stubs/3.2/resource.py similarity index 100% rename from stubs/3.2/resource.py rename to mypy/stubs/3.2/resource.py diff --git a/stubs/3.2/select.py b/mypy/stubs/3.2/select.py similarity index 100% rename from stubs/3.2/select.py rename to mypy/stubs/3.2/select.py diff --git a/stubs/3.2/shlex.py b/mypy/stubs/3.2/shlex.py similarity index 100% rename from stubs/3.2/shlex.py rename to mypy/stubs/3.2/shlex.py diff --git a/stubs/3.2/shutil.py b/mypy/stubs/3.2/shutil.py similarity index 100% rename from stubs/3.2/shutil.py rename to mypy/stubs/3.2/shutil.py diff --git a/stubs/3.2/signal.py b/mypy/stubs/3.2/signal.py similarity index 100% rename from stubs/3.2/signal.py rename to mypy/stubs/3.2/signal.py diff --git a/stubs/3.2/socket.py b/mypy/stubs/3.2/socket.py similarity index 100% rename from stubs/3.2/socket.py rename to mypy/stubs/3.2/socket.py diff --git a/stubs/3.2/stat.py b/mypy/stubs/3.2/stat.py similarity index 100% rename from stubs/3.2/stat.py rename to mypy/stubs/3.2/stat.py diff --git a/stubs/3.2/string.py b/mypy/stubs/3.2/string.py similarity index 100% rename from stubs/3.2/string.py rename to mypy/stubs/3.2/string.py diff --git a/stubs/3.2/struct.py b/mypy/stubs/3.2/struct.py similarity index 100% rename from stubs/3.2/struct.py rename to mypy/stubs/3.2/struct.py diff --git a/stubs/3.2/subprocess.py b/mypy/stubs/3.2/subprocess.py similarity index 100% rename from stubs/3.2/subprocess.py rename to mypy/stubs/3.2/subprocess.py diff --git a/stubs/3.2/sys.py b/mypy/stubs/3.2/sys.py similarity index 100% rename from stubs/3.2/sys.py rename to mypy/stubs/3.2/sys.py diff --git a/stubs/3.2/sysconfig.py b/mypy/stubs/3.2/sysconfig.py similarity index 100% rename from stubs/3.2/sysconfig.py rename to mypy/stubs/3.2/sysconfig.py diff --git a/stubs/3.2/tarfile.py b/mypy/stubs/3.2/tarfile.py similarity index 100% rename from stubs/3.2/tarfile.py rename to mypy/stubs/3.2/tarfile.py diff --git a/stubs/3.2/tempfile.py b/mypy/stubs/3.2/tempfile.py similarity index 100% rename from stubs/3.2/tempfile.py rename to mypy/stubs/3.2/tempfile.py diff --git a/stubs/3.2/threading.py b/mypy/stubs/3.2/threading.py similarity index 100% rename from stubs/3.2/threading.py rename to mypy/stubs/3.2/threading.py diff --git a/stubs/3.2/time.py b/mypy/stubs/3.2/time.py similarity index 100% rename from stubs/3.2/time.py rename to mypy/stubs/3.2/time.py diff --git a/stubs/3.2/traceback.py b/mypy/stubs/3.2/traceback.py similarity index 100% rename from stubs/3.2/traceback.py rename to mypy/stubs/3.2/traceback.py diff --git a/stubs/3.2/types.py b/mypy/stubs/3.2/types.py similarity index 100% rename from stubs/3.2/types.py rename to mypy/stubs/3.2/types.py diff --git a/stubs/3.2/typing.py b/mypy/stubs/3.2/typing.py similarity index 100% rename from stubs/3.2/typing.py rename to mypy/stubs/3.2/typing.py diff --git a/stubs/3.2/unicodedata.py b/mypy/stubs/3.2/unicodedata.py similarity index 100% rename from stubs/3.2/unicodedata.py rename to mypy/stubs/3.2/unicodedata.py diff --git a/stubs/3.2/unittest.py b/mypy/stubs/3.2/unittest.py similarity index 100% rename from stubs/3.2/unittest.py rename to mypy/stubs/3.2/unittest.py diff --git a/stubs/3.2/urllib/__init__.py b/mypy/stubs/3.2/urllib/__init__.py similarity index 100% rename from stubs/3.2/urllib/__init__.py rename to mypy/stubs/3.2/urllib/__init__.py diff --git a/stubs/3.2/urllib/parse.py b/mypy/stubs/3.2/urllib/parse.py similarity index 100% rename from stubs/3.2/urllib/parse.py rename to mypy/stubs/3.2/urllib/parse.py diff --git a/stubs/3.2/urllib/request.py b/mypy/stubs/3.2/urllib/request.py similarity index 100% rename from stubs/3.2/urllib/request.py rename to mypy/stubs/3.2/urllib/request.py diff --git a/stubs/3.2/warnings.py b/mypy/stubs/3.2/warnings.py similarity index 100% rename from stubs/3.2/warnings.py rename to mypy/stubs/3.2/warnings.py diff --git a/stubs/3.2/weakref.py b/mypy/stubs/3.2/weakref.py similarity index 100% rename from stubs/3.2/weakref.py rename to mypy/stubs/3.2/weakref.py diff --git a/stubs/3.2/zipfile.py b/mypy/stubs/3.2/zipfile.py similarity index 100% rename from stubs/3.2/zipfile.py rename to mypy/stubs/3.2/zipfile.py diff --git a/stubs/3.2/zlib.py b/mypy/stubs/3.2/zlib.py similarity index 100% rename from stubs/3.2/zlib.py rename to mypy/stubs/3.2/zlib.py diff --git a/stubs/3.4/asyncio/__init__.py b/mypy/stubs/3.4/asyncio/__init__.py similarity index 100% rename from stubs/3.4/asyncio/__init__.py rename to mypy/stubs/3.4/asyncio/__init__.py diff --git a/stubs/3.4/asyncio/events.py b/mypy/stubs/3.4/asyncio/events.py similarity index 100% rename from stubs/3.4/asyncio/events.py rename to mypy/stubs/3.4/asyncio/events.py diff --git a/stubs/3.4/asyncio/futures.py b/mypy/stubs/3.4/asyncio/futures.py similarity index 100% rename from stubs/3.4/asyncio/futures.py rename to mypy/stubs/3.4/asyncio/futures.py diff --git a/stubs/3.4/asyncio/tasks.py b/mypy/stubs/3.4/asyncio/tasks.py similarity index 100% rename from stubs/3.4/asyncio/tasks.py rename to mypy/stubs/3.4/asyncio/tasks.py diff --git a/vm/mypy.h b/mypy/vm/mypy.h similarity index 100% rename from vm/mypy.h rename to mypy/vm/mypy.h diff --git a/vm/runtime.c b/mypy/vm/runtime.c similarity index 100% rename from vm/runtime.c rename to mypy/vm/runtime.c diff --git a/scripts/mypy b/scripts/mypy index a5c3153d21b7..516ffd7ffdd6 100755 --- a/scripts/mypy +++ b/scripts/mypy @@ -34,13 +34,12 @@ class Options: def main() -> None: - bin_dir = find_bin_directory() path, module, args, options = process_options(sys.argv[1:]) try: if options.target == build.TYPE_CHECK: - type_check_only(path, module, bin_dir, args, options) + type_check_only(path, module, args, options) elif options.target == build.C: - compile_to_c(path, module, bin_dir, args, options) + compile_to_c(path, module, args, options) else: raise RuntimeError('unsupported target %d' % options.target) except CompileError as e: @@ -49,37 +48,11 @@ def main() -> None: sys.exit(1) -def find_bin_directory() -> str: - """Find the directory that contains this script. - - This is used by build to find stubs and other data files. - """ - script = __file__ - # Follow up to 5 symbolic links (cap to avoid cycles). - for i in range(5): - if os.path.islink(script): - script = readlinkabs(script) - else: - break - return os.path.dirname(script) - - -def readlinkabs(link: str) -> str: - """Return an absolute path to symbolic link destination.""" - # Adapted from code by Greg Smith. - assert os.path.islink(link) - path = os.readlink(link) - if os.path.isabs(path): - return path - return os.path.join(os.path.dirname(link), path) - - -def type_check_only(path: str, module: str, bin_dir: str, args: List[str], +def type_check_only(path: str, module: str, args: List[str], options: Options) -> None: # Type check the program and dependencies and translate to Python. build.build(path, module=module, - bin_dir=bin_dir, target=build.TYPE_CHECK, pyversion=options.pyversion, custom_typing_module=options.custom_typing_module, @@ -103,14 +76,14 @@ def type_check_only(path: str, module: str, bin_dir: str, args: List[str], sys.exit(status) -def compile_to_c(path: str, module: str, bin_dir: str, args: List[str], +def compile_to_c(path: str, module: str, args: List[str], options: Options) -> None: assert not module # Not supported yet assert not args # Not supported yet assert options.pyversion == 3 # Compile the program to C (also generate binary by default). - result = build.build(path, target=build.C, bin_dir=bin_dir, + result = build.build(path, target=build.C, flags=options.build_flags) if build.COMPILE_ONLY not in options.build_flags: diff --git a/setup.py b/setup.py index 5bcb4986ac9b..a7938b3a8fb9 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ import os.path import sys -from distutils.core import setup +from setuptools import setup if sys.version_info < (3, 2, 0): sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n") @@ -22,20 +22,6 @@ interpreter. '''.lstrip() -stubs = [] - -for version in ['3.4', '3.3', '3.2', '2.7']: - base = os.path.join('stubs', version) - if not os.path.exists(base): - os.mkdir(base) - - stub_dirs = [''] + [name for name in os.listdir(base) - if os.path.isdir(os.path.join(base, name))] - for stub_dir in stub_dirs: - target = os.path.join('lib', 'mypy', 'stubs', version, stub_dir) - files = glob.glob(os.path.join(base, stub_dir, '*.py')) - stubs.append((target, files)) - classifiers = [ 'Development Status :: 2 - Pre-Alpha', 'Environment :: Console', @@ -57,9 +43,9 @@ license='MIT License', platforms=['POSIX'], package_dir={'': 'lib-typing/3.2', 'mypy': 'mypy'}, + package_data={'mypy': ['stubs/*/*.pyx', 'lib/*py', 'vm/*']}, py_modules=['typing'], packages=['mypy'], scripts=['scripts/mypy'], - data_files=stubs, classifiers=classifiers, ) diff --git a/stubs/3.3/do-not-remove b/stubs/3.3/do-not-remove deleted file mode 100644 index e69de29bb2d1..000000000000 From 4e7e1a61c589df6ba7cbc5995a2620ba79c7a4e0 Mon Sep 17 00:00:00 2001 From: Marcell Vazquez-Chanlatte Date: Sun, 10 Aug 2014 15:49:16 -0700 Subject: [PATCH 2/4] switch to entry point and incorrect extension on stubs --- scripts/mypy => mypy/main.py | 4 ---- setup.py | 6 ++++-- 2 files changed, 4 insertions(+), 6 deletions(-) rename scripts/mypy => mypy/main.py (99%) diff --git a/scripts/mypy b/mypy/main.py similarity index 99% rename from scripts/mypy rename to mypy/main.py index 516ffd7ffdd6..5d1928aa3ea9 100755 --- a/scripts/mypy +++ b/mypy/main.py @@ -167,7 +167,3 @@ def usage(msg: str = None) -> None: def fail(msg: str) -> None: sys.stderr.write('%s\n' % msg) sys.exit(1) - - -if __name__ == '__main__': - main() diff --git a/setup.py b/setup.py index a7938b3a8fb9..a3a6dbf10ea8 100644 --- a/setup.py +++ b/setup.py @@ -43,9 +43,11 @@ license='MIT License', platforms=['POSIX'], package_dir={'': 'lib-typing/3.2', 'mypy': 'mypy'}, - package_data={'mypy': ['stubs/*/*.pyx', 'lib/*py', 'vm/*']}, + package_data={'mypy': ['stubs/*/*.py', 'lib/*py', 'vm/*']}, py_modules=['typing'], packages=['mypy'], - scripts=['scripts/mypy'], + entry_points={ + 'console_scripts': ['mypy = mypy.main:main'] + }, classifiers=classifiers, ) From 7df281cb61b5c09b7cbf8dba4c880249ddd5b688 Mon Sep 17 00:00:00 2001 From: Marcell Vazquez-Chanlatte Date: Sun, 10 Aug 2014 20:48:09 -0700 Subject: [PATCH 3/4] added codec line to fix encoding issues --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index a3a6dbf10ea8..d48b7a540e7f 100644 --- a/setup.py +++ b/setup.py @@ -5,6 +5,8 @@ import os.path import sys +from mypy.codec import register + from setuptools import setup if sys.version_info < (3, 2, 0): From ebc012f629c817b963a1035ab3f916eb123f864f Mon Sep 17 00:00:00 2001 From: Marcell Vazquez-Chanlatte Date: Mon, 11 Aug 2014 22:32:37 -0700 Subject: [PATCH 4/4] fix package_dir declaration and typing modules -> packages --- lib-typing/2.7/__init__.py | 0 lib-typing/2.7/{typing.py => typing/__init__.py} | 0 lib-typing/2.7/{ => typing}/setup.py | 0 lib-typing/2.7/{ => typing}/test_typing.py | 0 lib-typing/3.2/__init__.py | 0 lib-typing/3.2/{typing.py => typing/__init__.py} | 0 lib-typing/3.2/{ => typing}/test_typing.py | 0 setup.py | 6 +++--- 8 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 lib-typing/2.7/__init__.py rename lib-typing/2.7/{typing.py => typing/__init__.py} (100%) rename lib-typing/2.7/{ => typing}/setup.py (100%) rename lib-typing/2.7/{ => typing}/test_typing.py (100%) create mode 100644 lib-typing/3.2/__init__.py rename lib-typing/3.2/{typing.py => typing/__init__.py} (100%) rename lib-typing/3.2/{ => typing}/test_typing.py (100%) diff --git a/lib-typing/2.7/__init__.py b/lib-typing/2.7/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib-typing/2.7/typing.py b/lib-typing/2.7/typing/__init__.py similarity index 100% rename from lib-typing/2.7/typing.py rename to lib-typing/2.7/typing/__init__.py diff --git a/lib-typing/2.7/setup.py b/lib-typing/2.7/typing/setup.py similarity index 100% rename from lib-typing/2.7/setup.py rename to lib-typing/2.7/typing/setup.py diff --git a/lib-typing/2.7/test_typing.py b/lib-typing/2.7/typing/test_typing.py similarity index 100% rename from lib-typing/2.7/test_typing.py rename to lib-typing/2.7/typing/test_typing.py diff --git a/lib-typing/3.2/__init__.py b/lib-typing/3.2/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib-typing/3.2/typing.py b/lib-typing/3.2/typing/__init__.py similarity index 100% rename from lib-typing/3.2/typing.py rename to lib-typing/3.2/typing/__init__.py diff --git a/lib-typing/3.2/test_typing.py b/lib-typing/3.2/typing/test_typing.py similarity index 100% rename from lib-typing/3.2/test_typing.py rename to lib-typing/3.2/typing/test_typing.py diff --git a/setup.py b/setup.py index d48b7a540e7f..de11baec2ee1 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ from mypy.codec import register -from setuptools import setup +from setuptools import setup, find_packages if sys.version_info < (3, 2, 0): sys.stderr.write("ERROR: You need Python 3.2 or later to use mypy.\n") @@ -44,10 +44,10 @@ url='http://www.mypy-lang.org/', license='MIT License', platforms=['POSIX'], - package_dir={'': 'lib-typing/3.2', 'mypy': 'mypy'}, + package_dir={'typing': 'lib-typing/3.2/typing', 'mypy': 'mypy'}, package_data={'mypy': ['stubs/*/*.py', 'lib/*py', 'vm/*']}, py_modules=['typing'], - packages=['mypy'], + packages=find_packages(), entry_points={ 'console_scripts': ['mypy = mypy.main:main'] },