Skip to content

No console entry point for Windows #1226

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

Closed
johnthagen opened this issue Feb 20, 2016 · 21 comments
Closed

No console entry point for Windows #1226

johnthagen opened this issue Feb 20, 2016 · 21 comments

Comments

@johnthagen
Copy link
Contributor

On Windows 10 x64 using Python 3.5.1:

>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:

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

This will work on Linux and Windows.

@gvanrossum
Copy link
Member

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 :-).

@refi64
Copy link
Contributor

refi64 commented Feb 21, 2016

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

@johnthagen
Copy link
Contributor Author

@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?

@gvanrossum
Copy link
Member

gvanrossum commented Feb 26, 2016 via email

@johnthagen
Copy link
Contributor Author

@gvanrossum Not one that I am aware of. All of the places I've found have stated that setuptools is the solution.

setuptools Documentation explains how the Windows .exe's are created

@gnprice gnprice modified the milestone: 0.3.3 Mar 1, 2016
@gvanrossum
Copy link
Member

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

@johnthagen
Copy link
Contributor Author

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:

$ mypy

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

@refi64
Copy link
Contributor

refi64 commented Mar 2, 2016

Again, simple fix: use a batch file!

@gvanrossum
Copy link
Member

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?

@ghost
Copy link

ghost commented Aug 31, 2016

Because I've decided to make life hard for myself: I don't think a somewhat simple bat file is enough, unless its generated on install (which then becomes a console entry point pretty much), or has extra logic added (which I don't think anyone wants to do, but would be a solution)

I have python 3.5 installed in Program Files (as is suggested by the installer), and I have pip installing to the --user location C:\Users\Username\AppData\Roaming\Python\Python35\<subfolders>

C:\somepath>where python
C:\Program Files\Python35\python.exe

C:\somepath>where mypy
C:\Users\Username\AppData\Roaming\Python\Python35\Scripts\mypy
C:\Users\Username\AppData\Roaming\Python\Python35\Scripts\mypy.bat

C:\somepath>mypy
'"C:\Users\Username\AppData\Roaming\Python\Python35\Scripts\..\python"' is not recognized as an internal or external command, operable program or batch file.

(since the bat file tries to access ../python from mypy.bat's location)

of course py -3 -m mypy still works fine, but I figured it would be worth mentioning!

@refi64
Copy link
Contributor

refi64 commented Aug 31, 2016

@Socialery Hmm... Maybe setup.py should somehow process the .bat file and hardcode the correct Python location...

Either that, or Windows can burn in a violent fire. I kind of like that option better.

@gvanrossum
Copy link
Member

gvanrossum commented Aug 31, 2016 via email

@johnthagen
Copy link
Contributor Author

Just want to throw out that setuptools really does have support for this (console entry points), and it works great in my experience. Don't think mypy needs to reinvent this.

Is there really a solid reason not to use the solution that has been used many times over by other Python packages?

@gvanrossum
Copy link
Member

Have you seen #1875? That was an attempt at adding a console entry point, but the author never got it to work. Feel free to submit a PR that works!

@gvanrossum gvanrossum reopened this Sep 1, 2016
@johnthagen
Copy link
Contributor Author

johnthagen commented Sep 1, 2016

Edit: Not sure if I'll have time to work on this, so opening it up for others to work on.

@gvanrossum
Copy link
Member

Maybe it's time to reconsider this? At least we're now using setuptools!

@alexandrul
Copy link
Contributor

@johnthagen could you test this proof of concept, please? https://github.com/alexandrul-ci/mypy/

@johnthagen
Copy link
Contributor Author

@alexandrul

I tried this on a Windows 10 x64 host running Python 3.6.0.

> py -3.6 -m venv venv
> Scripts\activate.bat

# Checked out https://github.com/alexandrul-ci/mypy/

> pip install "C:\Users\User\PycharmProjects\mypy"
Processing c:\users\user\pycharmprojects\mypy
Collecting typed-ast>=0.6.3 (from mypy==0.480.dev0)
  Using cached typed_ast-0.6.3-cp36-cp36m-win_amd64.whl
Installing collected packages: typed-ast, mypy
  Running setup.py install for mypy ... done
Successfully installed mypy-0.480.dev0 typed-ast-0.6.3
> mypy -V
mypy 0.480-dev
> mypy --help
usage: mypy [-h] [-v] [-V] [--python-version x.y] [--platform PLATFORM] [-2]
            [--ignore-missing-imports]

Appears to be working.

@alexandrul
Copy link
Contributor

@johnthagen thank you

On my PC I have tested it with an altered sample from mypy, I have the same issues reported with my version as with the original 0.470.

@gvanrossum gvanrossum removed this from the 0.4.x milestone Mar 29, 2017
@emmatyping
Copy link
Member

I believe this can be closed as we are using the newer entry point method.

@ghost
Copy link

ghost commented Jul 2, 2017

just checked for my edge-case of a python install, seems to work great now (well, the entry point does at least!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants