New submission from Josh Triplett <j...@joshtriplett.org>:

I'm writing this issue on behalf of the Rust project.

The build system for the Rust compiler is a Python 3 script `x.py`, which 
orchestrates the build process for a user even if they don't already have Rust 
installed. (For instance, `x.py build`, `x.py test`, and various command-line 
arguments for more complex cases.)

We currently run into various issues making this script easy for people to use 
on all common platforms people build Rust on: Windows, macOS, and Linux.

If we use a shebang of `#!/usr/bin/env python3`, then x.py works for macOS and 
Linux users, and also works on Windows systems that install Python via the 
Windows store, but fails to run on Windows systems that install via the 
official Python installer, requiring users to explicitly invoke Python 3 on the 
script, and adding friction, support issues, and complexity to our 
documentation to help users debug that situation.

If we use a shebang of `#!/usr/bin/env python`, then x.py works for Windows 
users, fails on some modern macOS systems, works on other modern macOS systems 
(depending on installation method I think, e.g. homebrew vs Apple), fails on 
some modern Linux systems, and on macOS and Linux systems where it *does* work, 
it might be python2 or python3. So in practice, people often have to explicitly 
run `python3 x.py`, which again results in friction, support issues, and 
complexity in our documentation.

We've even considered things like `#!/bin/sh` and then writing a shell script 
hidden inside a Python triple-quoted string, but that doesn't work well on 
Windows where we can't count on the presence of a shell.

We'd love to write a single shebang that works for all of Windows, macOS, and 
Linux systems, and doesn't resort in recurring friction or support issues for 
us across the wide range of systems that our users use.

As far as we can tell, `#!/usr/bin/env python3` would work on all platforms, if 
the Python installer for Windows shipped a `python3.exe` and handled that 
shebang by using `python3.exe` as the interpreter.

Is that something that the official Python installer could consider adding, to 
make it easy for us to supply cross-platform Python 3 scripts that work out of 
the box for all our users?

Thank you,
Josh Triplett, on behalf of many Rust team members

----------
messages: 412553
nosy: joshtriplett
priority: normal
severity: normal
status: open
title: Portable python3 shebang for Windows, macOS, and Linux
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46645>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to