On Sun, Feb 15, 2015 at 5:43 PM, Paul Moore <p.f.mo...@gmail.com> wrote: > On 15 February 2015 at 16:15, Petr Viktorin <encu...@gmail.com> wrote: >> On Sun, Feb 15, 2015 at 2:21 PM, Paul Moore <p.f.mo...@gmail.com> wrote: >>> So the usage would be something like >>> >>> python -m zipapp [options] dir_to_zip >>> >>> Options: >>> -p <interpreter> The interpreter to use on the shebang line >>> (defaulting to /usr/bin/env python) >> >> On many systems this default would mean Python 2. Even if the official >> recommendation changes for 3.5, the status quo might linger for a few >> years. >> On the other hand, the number of distros that don't ship Python 3 is >> small, and the reason they're slow-moving tends to be stability and/or >> compliance, so they're not the target audience for zipapp. And the >> python3 symlink is not going away any time soon. >> So I'd suggest `/usr/bin/env python3` for the default. > > But that will fail for users who only have Python 2 installed. And it > won't pick up an activated virtualenv (assuming virtualenvs on Unix > don't include a python3 command, which I believe is true - it > certainly won't on Windows).
Yes, it would fail with only Python 2 installed. I don't think that's a problem. On POSIXy systems the "python3" symlink is created in all venvs. I thought (perhaps naïvely) that Windows doesn't do shebangs natively, so there's some Python-specific mechanism around them, which should handle "python3". If the app was single-source compatible with both 2 and 3, then `/usr/bin/env python` would be a good choice. But I don't think apps (as opposed to libraries) have much incentive to keep the backwards compatibility. > As a Windows user, I believe that the command "python" should run the > version of Python that you choose to be your default. I know it's not > quite that simple on Unix, and the system "python" command is > typically Python 2, with "python3" for the system Python 3 version, > but I also know that tools like pyenv work like that. Equally, I've > seen lots of scripts with "#!/usr/bin/env python" as the shebang line, > and none with "#!/usr/bin/env python3". That may just be my limited > experience with Unix though. On Linux, what version "python" is depends on the distro. Currently the recommendation from Python upstream is for it to be Python 2, though, and I know of just one distro that does not do this (Arch, because it switched before the recommendation was put in place). If you're in a venv, then of "python" is that venv's Python, of course. But the default mode of operation for Python-unaware users is to not be in a venv. > I don't really want "#!/usr/bin/env python3" as the default shebang on > Windows (at a minimum, it would do the wrong thing for my current > environment). I'm open to advice from the Unix users as to how to set > things up better on Unix, but there's a whole new set of problems that > will arise as soon as we have different defaults on Unix and Windows, > so IMO there would need to be pretty significant benefits to justify > doing that. I'm not familiar with how the shebang works on Windows, but if "/usr/bin/env python3" breaks things, I find it highly unfortunate. > And of course it *is* only a default - users can set whatever they > want. (But getting defaults right is important, so that's not to > dismiss the point). I'm afraid the point is whether it's even possible to have a shebang that does the right thing on both platforms. _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com