-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Wheel scripts don't get command line wrappers on Windows #2596
Comments
Regarding wrapping in an exe, yes it is important to do this. I tried to explain why in http://paul-moores-notes.readthedocs.org/en/latest/wrappers.html but basically Windows doesn't treat anything other than As regards Just as a note, on Windows the "correct interpreter" should be written with double quotes if needed to protect any spaces in the filename, and should be encoded in UTF-8 assuming there's no BOM in the file (see https://hg.python.org/cpython/file/1aad901e0307/PC/launcher.c#l1140). On Unix it should probably use (In practice, I've had problems getting a UTF-8 encoded shebang to work with non-ASCII characters on Windows, so be prepared to hit bugs in that area. You wouldn't be alone, it looks like distlib's exe wrappers, which pip uses for |
Thanks, that piece was interesting reading; I may find a use for shimmy at some point. I'll look into adding shim exes for script files. |
I started looking into this, and I realised that installing wheels with entry points now creates a script that does a direct import and call instead of going through However, is there already an issue for this: there is an extra blank line being inserted after the shebang, so the coding comment ends up on the third line: #!/home/takluyver/.virtualenvs/ipy-release/bin/python3
# -*- coding: utf-8 -*- I believe the coding comment only takes effect if it's on the first two lines, so this will be ineffective. I don't think it would ever actually be a problem - on Python 3, UTF-8 is already the default, and on Python 2, the module name and function name have to be ASCII anyway. But if you're putting the encoding comment in, you may as well do it properly. |
Hello, I'm changing the way I package the python modules for my application and we are using windows and have systems built around the .exe in the script folder. Is this being looked into ? takluyer if not could you give me a part to look at as from pfmoor's comment it seem that it is an important part of the install process for windows. |
In fact the latest PIP does create them if installing to a default directory but not if you use the --target== options. otherwise just a single .bat file is created. I think i can work around this locally now. |
@guyverthree it's just not a problem for me any more, because I decided to use |
Is this resolved? If not, what's the appropriate action to be done toward fixing this? |
From my point of view, the appropriate action is to include entry points (and specifically console_scripts) in the next version of the wheel spec, so they're a proper standard rather than something defined by usage. Then that could be the recommended way to package command line interfaces, rather than putting separate script files in the distribution. |
A brief follow-up: while entry points are not yet part of any wheel spec, we did specify their mechanism in the Python Packaging User Guide. So the de-facto spec is a bit less implementation defined now: https://packaging.python.org/specifications/entry-points/ I'm still inclined to say that a future version of the wheel spec should deprecate the scripts directory, but if you want to close this as a pip issue, I won't object. |
When installing a wheel on Windows, if it specifies setuptools
console_scripts
orgui_scripts
entry points, pip creates an exe wrapper so that it can be directly invoked at the command line. Scripts supplied in(data)/scripts/
with a#!python
shebang, as described in PEP 427, however, do not get such a wrapper. Generating them is a recommend feature for installers according to the PEP.I'm happy to work on this, since I'm creating a wheel-building tool that puts scripts in the
(data)/scripts/
directory.Side note: at least for console scripts, is there a good reason to wrap them in a .exe rather than a .cmd file, which would be easier to inspect? In my experience, writing a script.cmd file that does
"path\to\python.exe" "%~dp0\script"
serves to make a Python script executable from the command line.Crosslink pypa/flit#1.
The text was updated successfully, but these errors were encountered: