From b068687890d13ab0dfbf2519cb69b62e792c9d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:11:33 +0800 Subject: [PATCH 1/7] move mypyc to console_scripts --- scripts/mypyc => mypyc/__main__.py | 0 setup.py | 1 + 2 files changed, 1 insertion(+) rename scripts/mypyc => mypyc/__main__.py (100%) mode change 100755 => 100644 diff --git a/scripts/mypyc b/mypyc/__main__.py old mode 100755 new mode 100644 similarity index 100% rename from scripts/mypyc rename to mypyc/__main__.py diff --git a/setup.py b/setup.py index 04cd455070d7..a548446f8509 100644 --- a/setup.py +++ b/setup.py @@ -186,6 +186,7 @@ def run(self): 'stubgen=mypy.stubgen:main', 'stubtest=mypy.stubtest:main', 'dmypy=mypy.dmypy.client:console_entry', + 'mypyc=mypyc.__main__:main', ]}, classifiers=classifiers, cmdclass=cmdclass, From c5b49f6dbfbb53b684b67d18a7ed37cebdb19adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:13:38 +0800 Subject: [PATCH 2/7] fix --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index a548446f8509..1a43c915d362 100644 --- a/setup.py +++ b/setup.py @@ -181,7 +181,6 @@ def run(self): ext_modules=ext_modules, packages=find_packages(), package_data={'mypy': package_data}, - scripts=['scripts/mypyc'], entry_points={'console_scripts': ['mypy=mypy.__main__:console_entry', 'stubgen=mypy.stubgen:main', 'stubtest=mypy.stubtest:main', From 436c2f87e5b4965dc3bbd4c2ff59327e445011f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:16:34 +0800 Subject: [PATCH 3/7] fix --- mypyc/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/mypyc/__main__.py b/mypyc/__main__.py index 235814042d27..ac7c074c83a4 100644 --- a/mypyc/__main__.py +++ b/mypyc/__main__.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 """Mypyc command-line tool. Usage: From 98ac72eec7c867b17af89f5629b83e957d4ca726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:20:48 +0800 Subject: [PATCH 4/7] fix flake8 --- mypyc/__main__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mypyc/__main__.py b/mypyc/__main__.py index ac7c074c83a4..b8df3ae30a01 100644 --- a/mypyc/__main__.py +++ b/mypyc/__main__.py @@ -26,6 +26,7 @@ ) """ + def main() -> None: build_dir = 'build' # can this be overridden?? try: @@ -48,5 +49,6 @@ def main() -> None: cmd = subprocess.run([sys.executable, setup_file, 'build_ext', '--inplace'], env=env) sys.exit(cmd.returncode) + if __name__ == '__main__': main() From 7dab67f7361a7e1f8d66eb68ffd08d89f878cf40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:22:25 +0800 Subject: [PATCH 5/7] update CI and doc --- mypyc/doc/dev-intro.md | 4 ++-- tox.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mypyc/doc/dev-intro.md b/mypyc/doc/dev-intro.md index 11de9cdc0c8b..bf0c1a836874 100644 --- a/mypyc/doc/dev-intro.md +++ b/mypyc/doc/dev-intro.md @@ -73,11 +73,11 @@ compiled code. For example, you may want to do interactive testing or to run benchmarks. This is also handy if you want to inspect the generated C code (see Inspecting Generated C). -Run `scripts/mypyc` to compile a module to a C extension using your +Run `mypyc` to compile a module to a C extension using your development version of mypyc: ``` -$ scripts/mypyc program.py +$ mypyc program.py ``` This will generate a C extension for `program` in the current working diff --git a/tox.ini b/tox.ini index ac7cdc72fdb7..44334688b0ad 100644 --- a/tox.ini +++ b/tox.ini @@ -51,7 +51,7 @@ description = type check ourselves basepython = python3.7 commands = python -m mypy --config-file mypy_self_check.ini -p mypy -p mypyc - python -m mypy --config-file mypy_self_check.ini misc/proper_plugin.py scripts/mypyc + python -m mypy --config-file mypy_self_check.ini misc/proper_plugin.py [testenv:docs] description = invoke sphinx-build to build the HTML docs From e0ebf32d2b7b8538336195929e07cd100be82bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:23:34 +0800 Subject: [PATCH 6/7] fix flake8 --- mypyc/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypyc/__main__.py b/mypyc/__main__.py index b8df3ae30a01..a11426001f77 100644 --- a/mypyc/__main__.py +++ b/mypyc/__main__.py @@ -49,6 +49,6 @@ def main() -> None: cmd = subprocess.run([sys.executable, setup_file, 'build_ext', '--inplace'], env=env) sys.exit(cmd.returncode) - + if __name__ == '__main__': main() From 2d2268f2bd27e16b4ccd5a983e4af8785888d8ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E4=B9=9D=E9=BC=8E?= <109224573@qq.com> Date: Mon, 8 Nov 2021 22:42:54 +0800 Subject: [PATCH 7/7] fix test --- mypyc/test/test_commandline.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mypyc/test/test_commandline.py b/mypyc/test/test_commandline.py index 5dae26d294ab..5c80d0fddb1d 100644 --- a/mypyc/test/test_commandline.py +++ b/mypyc/test/test_commandline.py @@ -47,8 +47,7 @@ def run_case(self, testcase: DataDrivenTestCase) -> None: out = b'' try: # Compile program - cmd = subprocess.run([sys.executable, - os.path.join(base_path, 'scripts', 'mypyc')] + args, + cmd = subprocess.run([sys.executable, '-m', 'mypyc', *args], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd='tmp') if 'ErrorOutput' in testcase.name or cmd.returncode != 0: out += cmd.stdout