Changing default Python to 3.x

67 views
Skip to first unread message

Neil Hodgson

unread,
Mar 12, 2020, 12:45:50 AM3/12/20
to scite-i...@googlegroups.com
Much of the Python world is now using Python 3.x but on Unix, SciTE runs “python” which will often be Python 2.7 instead of “python3”. Changing this to “python3” would help users whose scripts may fail when run with the old interpreter. Those who need to run Python 2.x can override the setting in user or local properties as appropriate.

These would be the new global settings:

if PLAT_GTK
command.go.*.py=python3 -u "$(FileNameExt)"

if PLAT_MAC
command.go.*.py=python3 -u "$(FileNameExt)”

On Windows, “python” commonly runs the most recent version. However, PEP 397 added the “py” and “pyw” launchers which understand shbang lines (like “#!/usr/bin/env python3”) and interprets them as would be done on Unix. Therefore, these launchers should be used instead of “python” directly.

if PLAT_WIN
command.go.*.py=pyw -u "$(FileNameExt)"
command.go.subsystem.*.py=1
command.go.*.pyw=pyw -u "$(FileNameExt)"
command.go.subsystem.*.pyw=1

Neil

Neil Hodgson

unread,
Mar 15, 2020, 7:14:24 PM3/15/20
to scite-interest
A more complex version of this change was committed as
https://sourceforge.net/p/scintilla/scite/ci/43a6b7a9385298995f3cd19e90665e90dc50c7be/

An extra variable python.command is used for the preferred Python interpreter so it can be overridden easily.

For scripts without extensions, “python3” is now recognized in shbang lines like:
#!/usr/bin/env python3

Neil

Reply all
Reply to author
Forward
0 new messages