Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions distlib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
# check if Python is called on the first line with this expression
FIRST_LINE_RE = re.compile(b'^#!.*pythonw?[0-9.]*([ \t].*)?$')
SCRIPT_TEMPLATE = r'''# -*- coding: utf-8 -*-
import re
import sys
from %(module)s import %(import_name)s
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
if sys.argv[0].endswith('-script.pyw'):
sys.argv[0] = sys.argv[0][: -11]
elif sys.argv[0].endswith('.exe'):
sys.argv[0] = sys.argv[0][: -4]
sys.exit(%(func)s())
'''

Expand Down