Console entry points are just a short-hand equivalent to a script like:
#!python
# -*- coding: utf-8 -*-
import re
import sys
from ENTRYPOINT_MODULE import ENTRYPOINT_VARIABLE
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(ENTRYPOINT_VARIABLE())
The wheel installer has some flexibility in the exact text of the script it synthesizes – the above is what pip currently uses – but the semantics are standard and you could include the fully-written out script in your wheel instead if you wanted.
It looks like PEP 427’s text is actually a bit underspecified for exactly how #!python
lines are supposed to be handled – you could argue that writing #!python -Xutf8
is already spec-compliant. Though this currently a moot point, since no wheel installers support it currently.
But anyway, if you want the shortest route to getting some kind of support for this, then it might be to get support for script shebang arguments into wheel installers and then ship an explicit script in your wheels. This would at least let you skip having to redesign entry points.
[Edit: okay from here I just learned that pip doesn’t generate .exe
wrappers for scripts with #!python
? I guess you’d have to fix this too. PEP 427 explicitly recommends that installers generate .exe wrappers for these scripts so this is arguably just a bug in pip.]