From asmeurer at gmail.com Sun Sep 4 21:07:35 2011 From: asmeurer at gmail.com (Aaron Meurer) Date: Sun, 4 Sep 2011 13:07:35 -0600 Subject: [Python-porting] Shebang lines for Python 3 Message-ID: Hi. We've been having a bit of a discussion about this on the SymPy (sympy.org) issue tracker. Is it proper to use "python3" in the shebang line of a script that should be run in Python 3? Something like #! /usr/bin/env python3 This shortcut works on my machine, but I don't know if it's universal to all Python 3 installs. This certainly would make it easier to me developing with those scripts, because I can just call ./script.py, but I'm wondering if it's proper to use that in the final (Python 3 version of the) release of the package. Aaron Meurer From regebro at gmail.com Mon Sep 5 07:32:56 2011 From: regebro at gmail.com (Lennart Regebro) Date: Mon, 5 Sep 2011 07:32:56 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: Message-ID: On Sun, Sep 4, 2011 at 21:07, Aaron Meurer wrote: > Hi. > > We've been having a bit of a discussion about this on the SymPy > (sympy.org) issue tracker. Is it proper to use "python3" in the > shebang line of a script that should be run in Python 3? Something > like > > #! /usr/bin/env python3 > It is proper, sure. This shortcut works on my machine, but I don't know if it's universal > to all Python 3 installs. I know archlinux uses just "python" for Python 3 and "python2" for Python 2. In general any install mechanism for your script should handle that, by for example using distutils or something. //Lennart -------------- next part -------------- An HTML attachment was scrubbed... URL: From 00ai99 at gmail.com Mon Sep 5 07:41:55 2011 From: 00ai99 at gmail.com (David Gowers (kampu)) Date: Mon, 5 Sep 2011 15:11:55 +0930 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: Message-ID: On Mon, Sep 5, 2011 at 3:02 PM, Lennart Regebro wrote: > On Sun, Sep 4, 2011 at 21:07, Aaron Meurer wrote: > >> Hi. >> >> We've been having a bit of a discussion about this on the SymPy >> (sympy.org) issue tracker. Is it proper to use "python3" in the >> shebang line of a script that should be run in Python 3? Something >> like >> >> #! /usr/bin/env python3 >> > > It is proper, sure. > > This shortcut works on my machine, but I don't know if it's universal >> to all Python 3 installs. > > > I know archlinux uses just "python" for Python 3 and "python2" for Python > 2. > Not that that stops you from using 'python3' or even 'python3.2' (though I wouldn't recommend the latter.). So no changes should be necessary. -------------- next part -------------- An HTML attachment was scrubbed... URL: From regebro at gmail.com Mon Sep 5 07:57:44 2011 From: regebro at gmail.com (Lennart Regebro) Date: Mon, 5 Sep 2011 07:57:44 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: Message-ID: On Mon, Sep 5, 2011 at 07:41, David Gowers (kampu) <00ai99 at gmail.com> wrote: > > > On Mon, Sep 5, 2011 at 3:02 PM, Lennart Regebro wrote: > >> On Sun, Sep 4, 2011 at 21:07, Aaron Meurer wrote: >> >>> Hi. >>> >>> We've been having a bit of a discussion about this on the SymPy >>> (sympy.org) issue tracker. Is it proper to use "python3" in the >>> shebang line of a script that should be run in Python 3? Something >>> like >>> >>> #! /usr/bin/env python3 >>> >> >> It is proper, sure. >> >> This shortcut works on my machine, but I don't know if it's universal >>> to all Python 3 installs. >> >> >> I know archlinux uses just "python" for Python 3 and "python2" for Python >> 2. >> > Not that that stops you from using 'python3' or even 'python3.2' (though I > wouldn't recommend the latter.). So no changes should be necessary. > Right, "python3.2 " would be the best way here. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hein at kde.org Mon Sep 5 09:54:00 2011 From: hein at kde.org (Eike Hein) Date: Mon, 05 Sep 2011 09:54:00 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: Message-ID: <4E648018.1050209@kde.org> On 9/4/2011 9:07 PM, Aaron Meurer wrote: > This shortcut works on my machine, but I don't know if it's universal > to all Python 3 installs. This certainly would make it easier to me > developing with those scripts, because I can just call ./script.py, > but I'm wondering if it's proper to use that in the final (Python 3 > version of the) release of the package. I remember reading somewhere that it's currently the recommendation of Python upstream to leave "python" at Python 2.x - possibly even indefinitely - and use "python3" for Python 3. Arch went against the grain there, it seems. I don't think "python3.2" makes sense unless you have some reason to think it won't work with 3.3. -- Best regards, Eike Hein From vlada.peric at gmail.com Mon Sep 5 11:42:23 2011 From: vlada.peric at gmail.com (=?UTF-8?Q?Vladimir_Peri=C4=87?=) Date: Mon, 5 Sep 2011 11:42:23 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: <4E648018.1050209@kde.org> References: <4E648018.1050209@kde.org> Message-ID: On Mon, Sep 5, 2011 at 9:54 AM, Eike Hein wrote: > On 9/4/2011 9:07 PM, Aaron Meurer wrote: >> >> This shortcut works on my machine, but I don't know if it's universal >> to all Python 3 installs. ?This certainly would make it easier to me >> developing with those scripts, because I can just call ./script.py, >> but I'm wondering if it's proper to use that in the final (Python 3 >> version of the) release of the package. > > I remember reading somewhere that it's currently the > recommendation of Python upstream to leave "python" > at Python 2.x - possibly even indefinitely - and use > "python3" for Python 3. Arch went against the grain > there, it seems. If that's the case, would it make sense to have 2to3 automatically convert these shebang lines? As a separate (perhaps not enabled by default) fixer maybe? > > I don't think "python3.2" makes sense unless you have > some reason to think it won't work with 3.3. > > > -- > Best regards, > Eike Hein > _______________________________________________ > Python-porting mailing list > Python-porting at python.org > http://mail.python.org/mailman/listinfo/python-porting > -- Vladimir Peri? From regebro at gmail.com Mon Sep 5 12:10:43 2011 From: regebro at gmail.com (Lennart Regebro) Date: Mon, 5 Sep 2011 12:10:43 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: <4E648018.1050209@kde.org> Message-ID: On Mon, Sep 5, 2011 at 11:42, Vladimir Peri? wrote: > On Mon, Sep 5, 2011 at 9:54 AM, Eike Hein wrote: > > On 9/4/2011 9:07 PM, Aaron Meurer wrote: > >> > >> This shortcut works on my machine, but I don't know if it's universal > >> to all Python 3 installs. This certainly would make it easier to me > >> developing with those scripts, because I can just call ./script.py, > >> but I'm wondering if it's proper to use that in the final (Python 3 > >> version of the) release of the package. > > > > I remember reading somewhere that it's currently the > > recommendation of Python upstream to leave "python" > > at Python 2.x - possibly even indefinitely - and use > > "python3" for Python 3. Arch went against the grain > > there, it seems. > > If that's the case, would it make sense to have 2to3 automatically > convert these shebang lines? As a separate (perhaps not enabled by > default) fixer maybe? That's not possible as you don't know what they should be. And in any case, the installer should adjust them (as distutils does, for example). //Lennart > -------------- next part -------------- An HTML attachment was scrubbed... URL: From asmeurer at gmail.com Mon Sep 5 21:22:21 2011 From: asmeurer at gmail.com (Aaron Meurer) Date: Mon, 5 Sep 2011 13:22:21 -0600 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: <4E648018.1050209@kde.org> Message-ID: OK, so actually Arch was the counterexample given in the other discussion too. Does Arch not include a python3 alias? Is it safe to say that Arch was really stupid for doing this, as it will break every single Python 2 script that someone wants to use, so that we can just ignore it? And can someone point to relevant distutils documentation on how to do this? I don't think that Vladimir's actually set up our setup.py script yet to handle our Python 3 work. Aaron Meurer On Mon, Sep 5, 2011 at 4:10 AM, Lennart Regebro wrote: > On Mon, Sep 5, 2011 at 11:42, Vladimir Peri? wrote: >> >> On Mon, Sep 5, 2011 at 9:54 AM, Eike Hein wrote: >> > On 9/4/2011 9:07 PM, Aaron Meurer wrote: >> >> >> >> This shortcut works on my machine, but I don't know if it's universal >> >> to all Python 3 installs. ?This certainly would make it easier to me >> >> developing with those scripts, because I can just call ./script.py, >> >> but I'm wondering if it's proper to use that in the final (Python 3 >> >> version of the) release of the package. >> > >> > I remember reading somewhere that it's currently the >> > recommendation of Python upstream to leave "python" >> > at Python 2.x - possibly even indefinitely - and use >> > "python3" for Python 3. Arch went against the grain >> > there, it seems. >> >> If that's the case, would it make sense to have 2to3 automatically >> convert these shebang lines? As a separate (perhaps not enabled by >> default) fixer maybe? > > That's not possible as you don't know what they should be. And in any case, > the installer should adjust them (as distutils does, for example). > //Lennart >> >> > > _______________________________________________ > Python-porting mailing list > Python-porting at python.org > http://mail.python.org/mailman/listinfo/python-porting > > From regebro at gmail.com Mon Sep 5 23:16:39 2011 From: regebro at gmail.com (Lennart Regebro) Date: Mon, 5 Sep 2011 23:16:39 +0200 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: <4E648018.1050209@kde.org> Message-ID: On Mon, Sep 5, 2011 at 21:22, Aaron Meurer wrote: > OK, so actually Arch was the counterexample given in the other > discussion too. Does Arch not include a python3 alias? They do. > Is it safe to say that Arch was really stupid for doing this IMO, yes. -------------- next part -------------- An HTML attachment was scrubbed... URL: From asmeurer at gmail.com Tue Sep 6 18:30:41 2011 From: asmeurer at gmail.com (Aaron Meurer) Date: Tue, 6 Sep 2011 10:30:41 -0600 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: <4E648018.1050209@kde.org> Message-ID: On Mon, Sep 5, 2011 at 3:16 PM, Lennart Regebro wrote: > On Mon, Sep 5, 2011 at 21:22, Aaron Meurer wrote: >> >> OK, so actually Arch was the counterexample given in the other >> discussion too. ?Does Arch not include a python3 alias? > > They do. Ah, so the Arch argument really isn't a good one, because /usr/bin/env python3 will still work there. And as far as I've heard, it will work everywhere else too. The real problem with Arch is that Python 2 stuff will break, not Python 3, and as we decided, this is Arch's fault, not ours. Aaron Meurer > >> >> ?Is it safe to?say that Arch was really stupid for doing this > > IMO, yes. > From barry at python.org Tue Sep 6 19:41:39 2011 From: barry at python.org (Barry Warsaw) Date: Tue, 6 Sep 2011 13:41:39 -0400 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: Message-ID: <20110906134139.493dc485@resist.wooz.org> On Sep 04, 2011, at 01:07 PM, Aaron Meurer wrote: >Is it proper to use "python3" in the shebang line of a script that should be >run in Python 3? Yes. See PEP 394: http://www.python.org/dev/peps/pep-0394/ While not yet approved, I think there's general consensus on the recommendations in the PEP. Cheers, -Barry From aaron.devore at gmail.com Wed Sep 7 01:33:44 2011 From: aaron.devore at gmail.com (Aaron DeVore) Date: Tue, 6 Sep 2011 16:33:44 -0700 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: References: <4E648018.1050209@kde.org> Message-ID: On Tue, Sep 6, 2011 at 9:30 AM, Aaron Meurer wrote: > Ah, so the Arch argument really isn't a good one, because /usr/bin/env > python3 will still work there. ?And as far as I've heard, it will work > everywhere else too. > > The real problem with Arch is that Python 2 stuff will break, not > Python 3, and as we decided, this is Arch's fault, not ours. Arch's justification was that switching /usr/bin/python would push developers and library writers to port to Python 3. It mostly just annoyed people, including me. However, Arch brought up a valid point: Python developers should not depend on "python" pointing to Python 2 for all eternity. Distributions, users, or sysadmins may not want: $ python to point to an obsolete version. Shebangs are fine if setup.py uses the scripts parameter to get shebang rewriting. Shebangs that require a run of 'sed' are less ideal, but workable. Using: subprocess.Popen(['python', 'script_name.py']) is bad. -Aaron DeVore From asmeurer at gmail.com Wed Sep 7 02:32:30 2011 From: asmeurer at gmail.com (Aaron Meurer) Date: Tue, 6 Sep 2011 18:32:30 -0600 Subject: [Python-porting] Shebang lines for Python 3 In-Reply-To: <20110906134139.493dc485@resist.wooz.org> References: <20110906134139.493dc485@resist.wooz.org> Message-ID: Excellent! That's exactly what I was looking for. It seems that python2 is not very widely adopted (yet), but I think that python3 is, and if anyone complains, we can point to this PEP/thread. After this PEP is accepted (or even before), would the Python core community consider adding a (potentially optional) fixer to 2to3 that changes shebang lines? Aaron Meurer On Tue, Sep 6, 2011 at 11:41 AM, Barry Warsaw wrote: > On Sep 04, 2011, at 01:07 PM, Aaron Meurer wrote: > >>Is it proper to use "python3" in the shebang line of a script that should be >>run in Python 3? > > Yes. > > See PEP 394: > > http://www.python.org/dev/peps/pep-0394/ > > While not yet approved, I think there's general consensus on the > recommendations in the PEP. > > Cheers, > -Barry > _______________________________________________ > Python-porting mailing list > Python-porting at python.org > http://mail.python.org/mailman/listinfo/python-porting >