threads / patch / 36596

patchStandardize python shebangs

Subject: [PATCH] Standardize python shebangs

## tl;dr

13 messages between May 7, 2014 and May 8, 2014. Diffs are folded; open one to read it.

replies: 12people: 4as markdown or json

Felipe Contreras· May 7, 2014, 10:03 UTC · lore
It's better if all our scripts use the same '/usr/bin/env python'.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/hooks/multimail/README                  | 6 +++---
 contrib/hooks/multimail/git_multimail.py        | 2 +-
 contrib/hooks/multimail/migrate-mailhook-config | 2 +-
 contrib/hooks/multimail/post-receive            | 2 +-
 contrib/svn-fe/svnrdump_sim.py                  | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)
Show changes to 5 files +7 −7

contrib/hooks/multimail/README, contrib/hooks/multimail/git_multimail.py, contrib/hooks/multimail/migrate-mailhook-config, contrib/hooks/multimail/post-receive, contrib/svn-fe/svnrdump_sim.py

diff --git a/contrib/hooks/multimail/README b/contrib/hooks/multimail/README
index 477d65f..cf0bcb8 100644
--- a/contrib/hooks/multimail/README
+++ b/contrib/hooks/multimail/README
@@ -76,10 +76,10 @@ Requirements
   The example scripts invoke Python using the following shebang line
   (following PEP 394 [1]):
 
-      #! /usr/bin/env python2
+      #! /usr/bin/env python
 
-  If your system's Python2 interpreter is not in your PATH or is not
-  called "python2", you can change the lines accordingly.  Or you can
+  If your system's Python interpreter is not in your PATH or is not
+  called "python", you can change the lines accordingly.  Or you can
   invoke the Python interpreter explicitly, for example via a tiny
   shell script like
 
diff --git a/contrib/hooks/multimail/git_multimail.py b/contrib/hooks/multimail/git_multimail.py
index 8b58ed6..f6dcdc6 100755
--- a/contrib/hooks/multimail/git_multimail.py
+++ b/contrib/hooks/multimail/git_multimail.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2
+#! /usr/bin/env python
 
 # Copyright (c) 2012-2014 Michael Haggerty and others
 # Derived from contrib/hooks/post-receive-email, which is
diff --git a/contrib/hooks/multimail/migrate-mailhook-config b/contrib/hooks/multimail/migrate-mailhook-config
index 04eeaac..fba0b90 100755
--- a/contrib/hooks/multimail/migrate-mailhook-config
+++ b/contrib/hooks/multimail/migrate-mailhook-config
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2
+#! /usr/bin/env python
 
 """Migrate a post-receive-email configuration to be usable with git_multimail.py.
 
diff --git a/contrib/hooks/multimail/post-receive b/contrib/hooks/multimail/post-receive
index 4d46828..4f2cf9d 100755
--- a/contrib/hooks/multimail/post-receive
+++ b/contrib/hooks/multimail/post-receive
@@ -1,4 +1,4 @@
-#! /usr/bin/env python2
+#! /usr/bin/env python
 
 """Example post-receive hook based on git-multimail.
 
diff --git a/contrib/svn-fe/svnrdump_sim.py b/contrib/svn-fe/svnrdump_sim.py
index 4e78a1c..bf20819 100755
--- a/contrib/svn-fe/svnrdump_sim.py
+++ b/contrib/svn-fe/svnrdump_sim.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 """
 Simulates svnrdump by replaying an existing dump from a file, taking care
 of the specified revision range.
-- 
1.9.2+fc1.25.g15bd061
Johan Herland· May 7, 2014, 10:27 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

On Wed, May 7, 2014 at 12:03 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

> It's better if all our scripts use the same '/usr/bin/env python'.

Only if they are source compatible with both Python2 and Python3. See PEP394 <URL: http://legacy.python.org/dev/peps/pep-0394/ >. Otherwise (for python2-only scripts) '/usr/bin/env python2' is the way to go.

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Felipe Contreras· May 7, 2014, 11:11 UTC · re: Johan Herland · lore

Re: [PATCH] Standardize python shebangs

Johan Herland wrote:
Show 7 quoted lines
> On Wed, May 7, 2014 at 12:03 PM, Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> > It's better if all our scripts use the same '/usr/bin/env python'.
> 
> Only if they are source compatible with both Python2 and Python3. See
> PEP394 <URL: http://legacy.python.org/dev/peps/pep-0394/ >. Otherwise
> (for python2-only scripts) '/usr/bin/env python2' is the way to go.
It doesn't matter. People and aistributions have to change them anyway.
-- 
Felipe Contreras
James Denholm· May 7, 2014, 12:03 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

On 7 May 2014 21:11:53 GMT+10:00, Felipe Contreras <felipe.contreras@gmail.com> wrote:
Show 10 quoted lines
>Johan Herland wrote:
>> On Wed, May 7, 2014 at 12:03 PM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>> > It's better if all our scripts use the same '/usr/bin/env python'.
>> 
>> Only if they are source compatible with both Python2 and Python3. See
>> PEP394 <URL: http://legacy.python.org/dev/peps/pep-0394/ >. Otherwise
>> (for python2-only scripts) '/usr/bin/env python2' is the way to go.
>
>It doesn't matter. People and aistributions have to change them anyway.

Yeah, but they shouldn't have to. The build process is already non-"sane", let's please not make it more so?

Moving all instances of "env python" to be "env python2", though, that I think is a reasonable solution (if this is even felt to be a problem).

Regards, James Denholm.

Johan Herland· May 7, 2014, 12:28 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

On Wed, May 7, 2014 at 1:11 PM, Felipe Contreras <felipe.contreras@gmail.com> wrote:

Show 10 quoted lines
> Johan Herland wrote:
>> On Wed, May 7, 2014 at 12:03 PM, Felipe Contreras
>> <felipe.contreras@gmail.com> wrote:
>> > It's better if all our scripts use the same '/usr/bin/env python'.
>>
>> Only if they are source compatible with both Python2 and Python3. See
>> PEP394 <URL: http://legacy.python.org/dev/peps/pep-0394/ >. Otherwise
>> (for python2-only scripts) '/usr/bin/env python2' is the way to go.
>
> It doesn't matter. People and aistributions have to change them anyway.

No, that's _exactly_ what PEP394 addresses. If we standardize on '/usr/bin/env python2' (I assume all our .py scripts are Python2) then they should work on _all_ distros, and Arch Linux would not have to do their current python -> python2 hack (which you referred in another thread).

If we instead standardize on '/usr/bin/env python' instead, we only end up annoying forward-looking distros that (want to) enable python == python3 (but obviously also provide python2 for as long as necessary).

...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net
Matthieu Moy· May 7, 2014, 18:06 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

Felipe Contreras <felipe.contreras@gmail.com> writes:
> It's better if all our scripts use the same '/usr/bin/env python'.
Why?
Using python2 for git_multimail.py is a deliberate decision:
https://github.com/mhagger/git-multimail/pull/2
(also, contrib/hooks/multimail/README says:
"The git-multimail project itself is currently hosted on GitHub:
    https://github.com/mhagger/git-multimail

We use the GitHub issue tracker to keep track of bugs and feature requests, and GitHub pull requests to exchange patches (though, if you prefer, you can send patches via the Git mailing list with cc to me). Please sign off your patches as per the Git project practice." )

Show 67 quoted lines
> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
> ---
>  contrib/hooks/multimail/README                  | 6 +++---
>  contrib/hooks/multimail/git_multimail.py        | 2 +-
>  contrib/hooks/multimail/migrate-mailhook-config | 2 +-
>  contrib/hooks/multimail/post-receive            | 2 +-
>  contrib/svn-fe/svnrdump_sim.py                  | 2 +-
>  5 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/contrib/hooks/multimail/README b/contrib/hooks/multimail/README
> index 477d65f..cf0bcb8 100644
> --- a/contrib/hooks/multimail/README
> +++ b/contrib/hooks/multimail/README
> @@ -76,10 +76,10 @@ Requirements
>    The example scripts invoke Python using the following shebang line
>    (following PEP 394 [1]):
>  
> -      #! /usr/bin/env python2
> +      #! /usr/bin/env python
>  
> -  If your system's Python2 interpreter is not in your PATH or is not
> -  called "python2", you can change the lines accordingly.  Or you can
> +  If your system's Python interpreter is not in your PATH or is not
> +  called "python", you can change the lines accordingly.  Or you can
>    invoke the Python interpreter explicitly, for example via a tiny
>    shell script like
>  
> diff --git a/contrib/hooks/multimail/git_multimail.py b/contrib/hooks/multimail/git_multimail.py
> index 8b58ed6..f6dcdc6 100755
> --- a/contrib/hooks/multimail/git_multimail.py
> +++ b/contrib/hooks/multimail/git_multimail.py
> @@ -1,4 +1,4 @@
> -#! /usr/bin/env python2
> +#! /usr/bin/env python
>  
>  # Copyright (c) 2012-2014 Michael Haggerty and others
>  # Derived from contrib/hooks/post-receive-email, which is
> diff --git a/contrib/hooks/multimail/migrate-mailhook-config b/contrib/hooks/multimail/migrate-mailhook-config
> index 04eeaac..fba0b90 100755
> --- a/contrib/hooks/multimail/migrate-mailhook-config
> +++ b/contrib/hooks/multimail/migrate-mailhook-config
> @@ -1,4 +1,4 @@
> -#! /usr/bin/env python2
> +#! /usr/bin/env python
>  
>  """Migrate a post-receive-email configuration to be usable with git_multimail.py.
>  
> diff --git a/contrib/hooks/multimail/post-receive b/contrib/hooks/multimail/post-receive
> index 4d46828..4f2cf9d 100755
> --- a/contrib/hooks/multimail/post-receive
> +++ b/contrib/hooks/multimail/post-receive
> @@ -1,4 +1,4 @@
> -#! /usr/bin/env python2
> +#! /usr/bin/env python
>  
>  """Example post-receive hook based on git-multimail.
>  
> diff --git a/contrib/svn-fe/svnrdump_sim.py b/contrib/svn-fe/svnrdump_sim.py
> index 4e78a1c..bf20819 100755
> --- a/contrib/svn-fe/svnrdump_sim.py
> +++ b/contrib/svn-fe/svnrdump_sim.py
> @@ -1,4 +1,4 @@
> -#!/usr/bin/python
> +#!/usr/bin/env python
>  """
>  Simulates svnrdump by replaying an existing dump from a file, taking care
>  of the specified revision range.
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Felipe Contreras· May 7, 2014, 19:06 UTC · re: Matthieu Moy · lore

Re: [PATCH] Standardize python shebangs

Matthieu Moy wrote:
Show 7 quoted lines
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> 
> > It's better if all our scripts use the same '/usr/bin/env python'.
> 
> Why?
> 
> Using python2 for git_multimail.py is a deliberate decision:
If you want to use python2, then use '/usr/bin/env python2'.
Show 9 quoted lines
> "The git-multimail project itself is currently hosted on GitHub:
> 
>     https://github.com/mhagger/git-multimail
> 
> We use the GitHub issue tracker to keep track of bugs and feature
> requests, and GitHub pull requests to exchange patches (though, if you
> prefer, you can send patches via the Git mailing list with cc to me).
> Please sign off your patches as per the Git project practice."
> )

If you are going to follow practices different than git.git, then multimail shouldn't live in 'contrib/'. Junio is already thretening to remove stuff out of contrib even when development behaves as the Git core does, so it makes more sense for stuff that doesn't.

-- 
Felipe Contreras
Matthieu Moy· May 7, 2014, 20:23 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 10 quoted lines
> Matthieu Moy wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>> 
>> > It's better if all our scripts use the same '/usr/bin/env python'.
>> 
>> Why?
>> 
>> Using python2 for git_multimail.py is a deliberate decision:
>
> If you want to use python2, then use '/usr/bin/env python2'.
Err, yes, this is what the code does before your patch.
Show 12 quoted lines
>> "The git-multimail project itself is currently hosted on GitHub:
>> 
>>     https://github.com/mhagger/git-multimail
>> 
>> We use the GitHub issue tracker to keep track of bugs and feature
>> requests, and GitHub pull requests to exchange patches (though, if you
>> prefer, you can send patches via the Git mailing list with cc to me).
>> Please sign off your patches as per the Git project practice."
>> )
>
> If you are going to follow practices different than git.git, then
> multimail shouldn't live in 'contrib/'.

git-multimail is not the only part of git.git that has a separate maintainer. Same goes for git-gui and gitk.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Felipe Contreras· May 7, 2014, 20:40 UTC · re: Matthieu Moy · lore

Re: [PATCH] Standardize python shebangs

Matthieu Moy wrote:
> Felipe Contreras <felipe.contreras@gmail.com> writes:
> > If you want to use python2, then use '/usr/bin/env python2'.
> 
> Err, yes, this is what the code does before your patch.
Not for all the instances.
Show 5 quoted lines
> > If you are going to follow practices different than git.git, then
> > multimail shouldn't live in 'contrib/'.
> 
> git-multimail is not the only part of git.git that has a separate
> maintainer. Same goes for git-gui and gitk.
They are not part of contrib.
-- 
Felipe Contreras
Matthieu Moy· May 7, 2014, 20:57 UTC · re: Felipe Contreras · lore

Re: [PATCH] Standardize python shebangs

Felipe Contreras <felipe.contreras@gmail.com> writes:
Show 7 quoted lines
> Matthieu Moy wrote:
>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>> > If you want to use python2, then use '/usr/bin/env python2'.
>> 
>> Err, yes, this is what the code does before your patch.
>
> Not for all the instances.

Well, I guess not all scripts require python2, hence not all scripts declare that they depend on python2.

And anyway, I don't see how changing python2 to python in git-multimail solves any problem.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
James Denholm· May 7, 2014, 22:19 UTC · re: Matthieu Moy · lore

Re: [PATCH] Standardize python shebangs

On 8 May 2014 06:57:13 GMT+10:00, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
Show 12 quoted lines
>Felipe Contreras <felipe.contreras@gmail.com> writes:
>
>> Matthieu Moy wrote:
>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>> > If you want to use python2, then use '/usr/bin/env python2'.
>>> 
>>> Err, yes, this is what the code does before your patch.
>>
>> Not for all the instances.
>
>Well, I guess not all scripts require python2, hence not all scripts
>declare that they depend on python2.

Does it make sense for git to have a strict subset of python scripts as version agnostic, though? Given that some scripts depend on python2 already, and hence we know that the user has python2, and these scripts run perfectly well on python2, why not mandate that the agnostic subset be run on python2?

Regards, James Denholm.

Matthieu Moy· May 8, 2014, 11:48 UTC · re: James Denholm · lore

Re: [PATCH] Standardize python shebangs

James Denholm <nod.helm@gmail.com> writes:
Show 17 quoted lines
> On 8 May 2014 06:57:13 GMT+10:00, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
>>Felipe Contreras <felipe.contreras@gmail.com> writes:
>>
>>> Matthieu Moy wrote:
>>>> Felipe Contreras <felipe.contreras@gmail.com> writes:
>>>> > If you want to use python2, then use '/usr/bin/env python2'.
>>>> 
>>>> Err, yes, this is what the code does before your patch.
>>>
>>> Not for all the instances.
>>
>>Well, I guess not all scripts require python2, hence not all scripts
>>declare that they depend on python2.
>
> Does it make sense for git to have a strict subset of python scripts as
> version agnostic, though? Given that some scripts depend on python2
> already, and hence we know that the user has python2,

No, we don't. People do not have to use _all_ Python scripts. The discussion started about git-multimail.py, which I use on a server which doesn't have python3, while my desktop (where I use other Git commands) has Python3.

It is very important that git-multimail keeps running with Python2 (ideally, it could be portable Python 2 or 3, but it's not so easy to do), but that would be strange to force even non-git-multimail-users to use Python2 for that.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Johan Herland· May 8, 2014, 12:20 UTC · re: Matthieu Moy · lore

Re: [PATCH] Standardize python shebangs

On Thu, May 8, 2014 at 1:48 PM, Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:

> It is very important that git-multimail keeps running with Python2
> (ideally, it could be portable Python 2 or 3, but it's not so easy to
> do), but that would be strange to force even non-git-multimail-users to
> use Python2 for that.
FWIW, the rules laid out in PEP394 should be very easy to follow:
 - If your script is Python2-only, use "#!/usr/bin/env python2"
 - If your script is Python3-only, use "#!/usr/bin/env python3"
 - If your script is Python2/3-agnostic, use "#!/usr/bin/env python"
...Johan
-- 
Johan Herland, <johan@herland.net>
www.herland.net

← back to recent threads