From e491b5d4aa0c40fa23805403c1993fd4a2e4864a Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Wed, 17 May 2017 21:54:21 -0700 Subject: [PATCH 1/3] use entry_points instead of custom scripts --- mypy/__main__.py | 8 +++++++- scripts/mypy.bat | 9 --------- scripts/stubgen | 20 -------------------- setup.py | 6 ++---- tmp-test-dirs/mypy-test-wz6fxoss/main | 1 + 5 files changed, 10 insertions(+), 34 deletions(-) delete mode 100644 scripts/mypy.bat delete mode 100755 scripts/stubgen create mode 100644 tmp-test-dirs/mypy-test-wz6fxoss/main diff --git a/mypy/__main__.py b/mypy/__main__.py index 0a6f79261a53..625242d100be 100644 --- a/mypy/__main__.py +++ b/mypy/__main__.py @@ -2,4 +2,10 @@ from mypy.main import main -main(None) + +def console_entry() -> None: + main(None) + + +if __name__ == '__main__': + main(None) diff --git a/scripts/mypy.bat b/scripts/mypy.bat deleted file mode 100644 index b89d68c753f6..000000000000 --- a/scripts/mypy.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off - -setlocal -if exist "%~dp0\python.exe" ( - "%~dp0\python" "%~dp0mypy" %* -) else ( - "%~dp0..\python" "%~dp0mypy" %* -) -endlocal diff --git a/scripts/stubgen b/scripts/stubgen deleted file mode 100755 index 9b2d05a97f65..000000000000 --- a/scripts/stubgen +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env python3 -"""Generator of dynamically typed draft stubs for arbitrary modules. - -This is just a wrapper script. Look at mypy/stubgen.py for the actual -implementation. -""" - -import os -import os.path -import sys - -file_dir = os.path.dirname(__file__) -parent_dir = os.path.join(file_dir, os.pardir) -if os.path.exists(os.path.join(parent_dir, '.git')): - # We are running from a git clone. - sys.path.insert(0, parent_dir) - -import mypy.stubgen - -mypy.stubgen.main() diff --git a/setup.py b/setup.py index 78c6a639ad0a..efc23f4a6fe4 100644 --- a/setup.py +++ b/setup.py @@ -94,9 +94,6 @@ def run(self): package_dir = {'mypy': 'mypy'} -scripts = ['scripts/mypy', 'scripts/stubgen'] -if os.name == 'nt': - scripts.append('scripts/mypy.bat') # These requirements are used when installing by other means than bdist_wheel. # E.g. "pip3 install ." or @@ -119,7 +116,8 @@ def run(self): package_dir=package_dir, py_modules=[], packages=['mypy'], - scripts=scripts, + entry_points={'console_scripts': ['mypy=mypy.__main__:console_entry', + 'stubgen=mypy.stubgen:main']}, data_files=data_files, classifiers=classifiers, cmdclass={'build_py': CustomPythonBuild}, diff --git a/tmp-test-dirs/mypy-test-wz6fxoss/main b/tmp-test-dirs/mypy-test-wz6fxoss/main new file mode 100644 index 000000000000..d7ea51ec67a3 --- /dev/null +++ b/tmp-test-dirs/mypy-test-wz6fxoss/main @@ -0,0 +1 @@ +import mod1 \ No newline at end of file From 9c72b110a397e0a29139762663a01564c34f9ee1 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Sat, 20 May 2017 17:46:09 -0700 Subject: [PATCH 2/3] remove extraneous test data --- tmp-test-dirs/mypy-test-wz6fxoss/main | 1 - 1 file changed, 1 deletion(-) delete mode 100644 tmp-test-dirs/mypy-test-wz6fxoss/main diff --git a/tmp-test-dirs/mypy-test-wz6fxoss/main b/tmp-test-dirs/mypy-test-wz6fxoss/main deleted file mode 100644 index d7ea51ec67a3..000000000000 --- a/tmp-test-dirs/mypy-test-wz6fxoss/main +++ /dev/null @@ -1 +0,0 @@ -import mod1 \ No newline at end of file From 3246efc86930d240b5ca8ba6b14f2a74942562b7 Mon Sep 17 00:00:00 2001 From: Ethan Smith Date: Fri, 26 May 2017 21:22:49 -0700 Subject: [PATCH 3/3] restore stubgen and mypy.bat scripts --- scripts/mypy.bat | 9 +++++++++ scripts/stubgen | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/mypy.bat create mode 100644 scripts/stubgen diff --git a/scripts/mypy.bat b/scripts/mypy.bat new file mode 100644 index 000000000000..b89d68c753f6 --- /dev/null +++ b/scripts/mypy.bat @@ -0,0 +1,9 @@ +@echo off + +setlocal +if exist "%~dp0\python.exe" ( + "%~dp0\python" "%~dp0mypy" %* +) else ( + "%~dp0..\python" "%~dp0mypy" %* +) +endlocal diff --git a/scripts/stubgen b/scripts/stubgen new file mode 100644 index 000000000000..9b2d05a97f65 --- /dev/null +++ b/scripts/stubgen @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +"""Generator of dynamically typed draft stubs for arbitrary modules. + +This is just a wrapper script. Look at mypy/stubgen.py for the actual +implementation. +""" + +import os +import os.path +import sys + +file_dir = os.path.dirname(__file__) +parent_dir = os.path.join(file_dir, os.pardir) +if os.path.exists(os.path.join(parent_dir, '.git')): + # We are running from a git clone. + sys.path.insert(0, parent_dir) + +import mypy.stubgen + +mypy.stubgen.main()