diff mbox series

[ovs-dev] m4: Try to use "python" as Python2 interpreter only as last resort

Message ID fc532f04964ddfac6d821cac2a9adb383b173421.1520525737.git.tredaelli@redhat.com
State Accepted
Headers show
Series [ovs-dev] m4: Try to use "python" as Python2 interpreter only as last resort | expand

Commit Message

Timothy Redaelli March 8, 2018, 4:15 p.m. UTC
This patch tries to find Python 2 as "python2", then "python2.7" and finally
"python".

This is needed since "/usr/bin/python" is used as Python 3 on some Linux
distributions (for example on Arch Linux) and on Fedora 28
"/usr/bin/python" will be deprecated [1]:
    "All scripts shall explicitly use /usr/bin/python2."

[1] https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
---
 m4/openvswitch.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Markos Chandras March 8, 2018, 4:36 p.m. UTC | #1
Hi Timothy,

On 08/03/18 16:15, Timothy Redaelli wrote:
> This patch tries to find Python 2 as "python2", then "python2.7" and finally
> "python".
> 
> This is needed since "/usr/bin/python" is used as Python 3 on some Linux
> distributions (for example on Arch Linux) and on Fedora 28
> "/usr/bin/python" will be deprecated [1]:
>     "All scripts shall explicitly use /usr/bin/python2."
> 
> [1] https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
> 
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> ---

So if I understand this correctly, in Fedora 28 and Arch Linux,
/usr/bin/python will actually be the python3 interp right? Why not
extend the macro then to also look for python3 and python3.5 python3.4
if no python2 or python exists? In openSUSE tumbleweed, there is no
python2, python2.X or python if you only have python3 installed so you
are only left with /usr/bin/python3 and /usr/bin/python3.X

Would you be able to amend your patch to look for these additional
python strings?
Timothy Redaelli March 8, 2018, 5:28 p.m. UTC | #2
On Thu, 8 Mar 2018 16:36:12 +0000
Markos Chandras <mchandras@suse.de> wrote:

> Hi Timothy,
> 
> On 08/03/18 16:15, Timothy Redaelli wrote:
> > This patch tries to find Python 2 as "python2", then "python2.7"
> > and finally "python".
> > 
> > This is needed since "/usr/bin/python" is used as Python 3 on some
> > Linux distributions (for example on Arch Linux) and on Fedora 28
> > "/usr/bin/python" will be deprecated [1]:
> >     "All scripts shall explicitly use /usr/bin/python2."
> > 
> > [1] https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
> > 
> > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> > ---  
> 
> So if I understand this correctly, in Fedora 28 and Arch Linux,
> /usr/bin/python will actually be the python3 interp right? Why not
> extend the macro then to also look for python3 and python3.5 python3.4
> if no python2 or python exists? In openSUSE tumbleweed, there is no
> python2, python2.X or python if you only have python3 installed so you
> are only left with /usr/bin/python3 and /usr/bin/python3.X
> 
> Would you be able to amend your patch to look for these additional
> python strings?
> 

Hi,
Arch Linux already have /usr/bin/python => python3.6 and from Fedora
28 /usr/bin/python MUST not be used directly in scripts.
Using /usr/bin/python will emit a big warning in stderr and many tests
will fail due to how autotest works.

In our Fedora spec file I workarounded it by setting the PYTHON
environment variable to /usr/bin/python2 [1], but any time an user wants
to build OVS on Fedora 28+ it must set the PYTHON variable
to /usr/bin/python2 until this commit is approved.

Currently, I'm working on some other patches/patchsets in order to
permit to build OVS when you only have python3 installed.

So this commit is only the first step since, currently, it's not
possible to build (and test) OVS with only python3 installed since the test
after my modification (inside OVS_CHECK_PYTHON) already check that the
python version is >= 2.7 < 3.0 and this is needed since this python
binary is also used launch some Python2 tests (make check).

Python 3 is found in the OVS_CHECK_PYTHON3 function that, currently,
only checks for "python3" and "python3.4" and, I think, we should add
also "python3.6" here. But it'll be another unrelated patchset.

[1]
https://src.fedoraproject.org/rpms/openvswitch/blob/master/f/openvswitch.spec#_325
Ben Pfaff March 8, 2018, 6:32 p.m. UTC | #3
On Thu, Mar 08, 2018 at 04:36:12PM +0000, Markos Chandras wrote:
> Hi Timothy,
> 
> On 08/03/18 16:15, Timothy Redaelli wrote:
> > This patch tries to find Python 2 as "python2", then "python2.7" and finally
> > "python".
> > 
> > This is needed since "/usr/bin/python" is used as Python 3 on some Linux
> > distributions (for example on Arch Linux) and on Fedora 28
> > "/usr/bin/python" will be deprecated [1]:
> >     "All scripts shall explicitly use /usr/bin/python2."
> > 
> > [1] https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
> > 
> > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
> > ---
> 
> So if I understand this correctly, in Fedora 28 and Arch Linux,
> /usr/bin/python will actually be the python3 interp right? Why not
> extend the macro then to also look for python3 and python3.5 python3.4
> if no python2 or python exists? In openSUSE tumbleweed, there is no
> python2, python2.X or python if you only have python3 installed so you
> are only left with /usr/bin/python3 and /usr/bin/python3.X

This particular macro checks for Python 2.x.  There is a separate macro
that checks for Python 3.x.
Ben Pfaff March 8, 2018, 6:33 p.m. UTC | #4
On Thu, Mar 08, 2018 at 05:15:37PM +0100, Timothy Redaelli wrote:
> This patch tries to find Python 2 as "python2", then "python2.7" and finally
> "python".
> 
> This is needed since "/usr/bin/python" is used as Python 3 on some Linux
> distributions (for example on Arch Linux) and on Fedora 28
> "/usr/bin/python" will be deprecated [1]:
>     "All scripts shall explicitly use /usr/bin/python2."
> 
> [1] https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
> 
> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>

Thanks, applied to master.  (If you consider this a bug fix for OVS 2.9,
let me know and I'll backport to branch-2.9.)
diff mbox series

Patch

diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
index 78082d4e0..3f301b23b 100644
--- a/m4/openvswitch.m4
+++ b/m4/openvswitch.m4
@@ -356,7 +356,7 @@  AC_DEFUN([OVS_CHECK_PYTHON],
         ovs_cv_python=$PYTHON
       else
         ovs_cv_python=no
-        for binary in python python2.7; do
+        for binary in python2 python2.7 python; do
           ovs_save_IFS=$IFS; IFS=$PATH_SEPARATOR
           for dir in $PATH; do
             IFS=$ovs_save_IFS