Repository: python/mypy

Issue:
No console entry point for Windows
On Windows 10 x64 using Python 3.5.1:

``` bat
>pip -V
pip 8.0.2
>pip install mypy-lang
>pip list
...
mypy-lang (0.3.1)
...
>mypy
'mypy' is not recognized as an internal or external command,
operable program or batch file.
```

I think what would be helpful for Windows users would be a `console_scripts` [`entry_point`](https://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords):

``` python
setuptools.setup(
    ...
    entry_points={
            'console_scripts': [
                'mypy = (INSERT MAIN MODULE):main',
            ],
```

This will work on Linux and Windows.

No console entry point for Windows
On Windows 10 x64 using Python 3.5.1:

``` bat
>pip -V
pip 8.0.2
>pip install mypy-lang
>pip list
...
mypy-lang (0.3.1)
...
>mypy
'mypy' is not recognized as an internal or external command,
operable program or batch file.
```

I think what would be helpful for Windows users would be a `console_scripts` [`entry_point`](https://pythonhosted.org/setuptools/setuptools.html#new-and-changed-setup-keywords):

``` python
setuptools.setup(
    ...
    entry_points={
            'console_scripts': [
                'mypy = (INSERT MAIN MODULE):main',
            ],
```

This will work on Linux and Windows.



Discussion:
Is there a way to do this without depending on setuptools? In my experience setuptools adds as many problems as it solves (different one though :-).

Why not add a `mypy.bat` that just calls `python -m mypy.__main__`?

@gvanrossum I haven't run into issues using `setuptools` personally, so would have to defer to you on that.  I'm curious to learn what some of these issues are, could you elaborate?

I can't elaborate on issues with setuptools, I just remember having been
really frustrated at various points in the past by things that broke due to
some setuptools cleverness. Isn't there some pip goodness that replaces
setuptools entry points?

@gvanrossum Not one that I am aware of. All of the places I've found have stated that `setuptools` is the solution.
- [Armin Ronacher's Click Documentation](http://click.pocoo.org/6/setuptools/)
- [Chris Warrick's Blog](https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/)
- [StackOverflow Question 1](http://stackoverflow.com/a/14002061/1398841)
- [StackOverflow Question 2](http://stackoverflow.com/a/18985818/1398841)
- [Python Packaging Authority Docs](https://python-packaging.readthedocs.org/en/latest/command-line-scripts.html)

[`setuptools` Documentation](https://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation)  explains how the Windows `.exe`'s are created

So, why can't we install scripts/mypy in the right place on Windows? That's what it's meant for.

I may be mistaken, but I think a fundamental issue on Windows is that there is no concept of a shebang line, so you need an executable `mypy.exe` rather than simply a script in order to let the user do:

``` lang=bat
$ mypy
```

Even if `scripts/mypy` is in the `PATH`, it can't be executed directly on Windows.

Again, simple fix: use a batch file!

I would like to have this fixed but I have no access to Windows. Can someone just contribute a .bat file as a PR, including the setup.py mods to install it?

Is there a way to do this without depending on setuptools? In my experience setuptools adds as many problems as it solves (different one though :-).

Why not add a `mypy.bat` that just calls `python -m mypy.__main__`?

@gvanrossum I haven't run into issues using `setuptools` personally, so would have to defer to you on that.  I'm curious to learn what some of these issues are, could you elaborate?

I can't elaborate on issues with setuptools, I just remember having been
really frustrated at various points in the past by things that broke due to
some setuptools cleverness. Isn't there some pip goodness that replaces
setuptools entry points?

@gvanrossum Not one that I am aware of. All of the places I've found have stated that `setuptools` is the solution.
- [Armin Ronacher's Click Documentation](http://click.pocoo.org/6/setuptools/)
- [Chris Warrick's Blog](https://chriswarrick.com/blog/2014/09/15/python-apps-the-right-way-entry_points-and-scripts/)
- [StackOverflow Question 1](http://stackoverflow.com/a/14002061/1398841)
- [StackOverflow Question 2](http://stackoverflow.com/a/18985818/1398841)
- [Python Packaging Authority Docs](https://python-packaging.readthedocs.org/en/latest/command-line-scripts.html)

[`setuptools` Documentation](https://pythonhosted.org/setuptools/setuptools.html#automatic-script-creation)  explains how the Windows `.exe`'s are created

So, why can't we install scripts/mypy in the right place on Windows? That's what it's meant for.

I may be mistaken, but I think a fundamental issue on Windows is that there is no concept of a shebang line, so you need an executable `mypy.exe` rather than simply a script in order to let the user do:

``` lang=bat
$ mypy
```

Even if `scripts/mypy` is in the `PATH`, it can't be executed directly on Windows.

Again, simple fix: use a batch file!

I would like to have this fixed but I have no access to Windows. Can someone just contribute a .bat file as a PR, including the setup.py mods to install it?


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -74,6 +74,10 @@ def find_data_files(base, globs):
 if sys.version_info < (3, 5, 0):
     package_dir[''] = 'lib-typing/3.2'
 
+scripts = ['scripts/mypy', 'scripts/stubgen']
+if os.name == 'nt':
+    scripts.append('scripts/mypy.bat')
+
 setup(name='mypy-lang',
       version=version,
       description=description,
@@ -86,7 +90,7 @@ def find_data_files(base, globs):
       package_dir=package_dir,
       py_modules=['typing'] if sys.version_info < (3, 5, 0) else [],
       packages=['mypy'],
-      scripts=['scripts/mypy', 'scripts/stubgen'],
+      scripts=scripts,
       data_files=data_files,
       classifiers=classifiers,
       )


Test patch: