Merge ~aixtools/cloud-init:hash-bang into cloud-init:master

Proposed by Michael Felt
Status: Work in progress
Proposed branch: ~aixtools/cloud-init:hash-bang
Merge into: cloud-init:master
Diff against target: 52 lines (+4/-5)
5 files modified
cloudinit/cmd/main.py (+0/-1)
doc/rtd/topics/format.rst (+1/-1)
tools/ccfg-merge-debug (+1/-1)
tools/make-mime.py (+1/-1)
tools/mock-meta.py (+1/-1)
Reviewer Review Type Date Requested Status
Scott Moser Needs Fixing
Server Team CI bot continuous-integration Approve
Review via email: mp+315610@code.launchpad.net

Commit message

behavior: Use #!/usr/bin/env python to call python

For files that are intended to be executed make sure python is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using this convention - this only makes
the style uniform - and updates the docs with this convention

Description of the change

unifies using "#!/usr/bin/env python" for cloud-init files that are intended to be executed.
Not only does this remove an assumption that python always exists in /usr/bin, it also permits
using/testing an alternate python by modifying the environment before cloud-init (tools) are called.

To post a comment you must log in.
Revision history for this message
Scott Moser (smoser) wrote :

the one thing that sucks about this is that virtualenv tries to help by making 'python3' have a name 'python'.

$ tox-venv py3 python --version
Python 3.5.3rc1

the change you've suggested here is probably right, but i really hate that it opens us up to getting the wrong python. (Ie, my feeling is that /usr/bin/python is and always will be python 2, where '/usr/bin/env python' might be python3).

most of that is rant, but the short result is that you now have to verify that the things you've changed from 'python' (python2) to 'env python' (python2 or python3) are python3 compatible.

Can you verify that ?

Revision history for this message
Michael Felt (aixtools) wrote :

On 25/01/2017 19:45, Scott Moser wrote:
> the one thing that sucks about this is that virtualenv tries to help by making 'python3' have a name 'python'.
>
> $ tox-venv py3 python --version
> Python 3.5.3rc1
>
> the change you've suggested here is probably right, but i really hate that it opens us up to getting the wrong python. (Ie, my feeling is that /usr/bin/python is and always will be python 2, where '/usr/bin/env python' might be python3).
>
> most of that is rant, but the short result is that you now have to verify that the things you've changed from 'python' (python2) to 'env python' (python2 or python3) are python3 compatible.
>
> Can you verify that ?
>
If I understand correctly - you want to go a step further: rather than
say 'python' specify literally, python2. And also make clear to users
that changing to python3 is not supported (i.e., letting /usr/bin/python
or /usr/bin/env python "point" at python3.

Michael

~aixtools/cloud-init:hash-bang updated
a02c005... by Michael Felt

Merge branch 'hash-bang' of ssh://git.launchpad.net/~aixtools/cloud-init into hash-bang

Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

Right now I'm thinking the thing to do is to take this, but use '#!/usr/bin/env python3'.
These tools are (or should be) python3 compatible.

Michael, Could you do that?

review: Needs Fixing
Revision history for this message
Michael Felt (aixtools) wrote :

I will - soon. Should be easy, but I will need to get aquainted with git
again.

So, unless you need it NOW - please wait.

Word to the wise. I know I have python3 "available" for AIX, I am not
sure about IBM and their packaging on cloud-init (afaik that is still
based on 0.7.5 - so I guess this won't hurt "them" directly either.).

Personally, I am quite disappointed in the python project - completely
not understanding that there are many things that may have been broken
"forever" does not (or read should not) means that they are okay.

Sincerely,

Michael

On 5/23/2017 4:32 PM, Scott Moser wrote:
> Review: Needs Fixing
>
> Right now I'm thinking the thing to do is to take this, but use '#!/usr/bin/env python3'.
> These tools are (or should be) python3 compatible.
>
> Michael, Could you do that?
>

Revision history for this message
Scott Moser (smoser) wrote :

Hi,
I'm going to move this to 'work in progress'.
Please move it back to 'Needs Review' when you've addressed the question above.
Thanks,
Scott

Unmerged commits

a02c005... by Michael Felt

Merge branch 'hash-bang' of ssh://git.launchpad.net/~aixtools/cloud-init into hash-bang

ee519d8... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For tools that are intended to be executed make sure python2 is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using #!/usr/bin/env - this only makes
the style uniform - and updates the docs with this convention

4c82f72... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For tools that are intended to be executed make sure python2 is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using #!/usr/bin/env - this only makes
the style uniform - and updates the docs with this convention
Note: python2 is being specified. As tools are verified to run
regardless of version - this could be changed to python

06e184a... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For files that are intended to be executed make sure python is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using this convention - this only makes
the style uniform - and updates the docs with this convention

1ef3f48... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For tools that are intended to be executed make sure python2 is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using #!/usr/bin/env - this only makes
the style uniform - and updates the docs with this convention
Note: python2 is being specified for one tool that is not yet python3 ready

4588c65... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For tools that are intended to be executed make sure python2 is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using #!/usr/bin/env - this only makes
the style uniform - and updates the docs with this convention
Note: python2 is being specified. As tools are verified to run
regardless of version - this could be changed to python

c519025... by Michael Felt

behavior: Use #!/usr/bin/env python to call python

For files that are intended to be executed make sure python is called
via the current environment rather than expect the correct python to
always be located at /usr/bin/python.
Note: several tools were already using this convention - this only makes
the style uniform - and updates the docs with this convention

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
2index 65b15ed..8ad5b03 100644
3--- a/cloudinit/cmd/main.py
4+++ b/cloudinit/cmd/main.py
5@@ -1,4 +1,3 @@
6-#!/usr/bin/python
7 #
8 # Copyright (C) 2012 Canonical Ltd.
9 # Copyright (C) 2012 Hewlett-Packard Development Company, L.P.
10diff --git a/doc/rtd/topics/format.rst b/doc/rtd/topics/format.rst
11index 436eb00..0b067a4 100644
12--- a/doc/rtd/topics/format.rst
13+++ b/doc/rtd/topics/format.rst
14@@ -35,7 +35,7 @@ Helper script to generate mime messages
15
16 .. code-block:: python
17
18- #!/usr/bin/python
19+ #!/usr/bin/env python
20
21 import sys
22
23diff --git a/tools/ccfg-merge-debug b/tools/ccfg-merge-debug
24index 1f08e0c..8d8db14 100755
25--- a/tools/ccfg-merge-debug
26+++ b/tools/ccfg-merge-debug
27@@ -1,4 +1,4 @@
28-#!/usr/bin/python
29+#!/usr/bin/env python
30
31 from cloudinit import handlers
32 from cloudinit.handlers import cloud_config as cc_part
33diff --git a/tools/make-mime.py b/tools/make-mime.py
34index 1272712..35b39e7 100755
35--- a/tools/make-mime.py
36+++ b/tools/make-mime.py
37@@ -1,4 +1,4 @@
38-#!/usr/bin/python
39+#!/usr/bin/env python
40
41 import argparse
42 import sys
43diff --git a/tools/mock-meta.py b/tools/mock-meta.py
44index a0d9944..ec55737 100755
45--- a/tools/mock-meta.py
46+++ b/tools/mock-meta.py
47@@ -1,4 +1,4 @@
48-#!/usr/bin/python
49+#!/usr/bin/env python
50
51 # Provides a somewhat random, somewhat compat, somewhat useful mock version of
52 # http://docs.amazonwebservices.com

Subscribers

People subscribed via source and target branches