[dpdk-dev] Force python scripts to run with python2
Checks
Commit Message
With python3 being the default in some distributions/installations,
shebang with just "python" will make the script run under version of
python that the scripts are not written for. In order to fix that and
mitigate future errors, use shebang properly and specify the python
version. That way the scripts will run in any distro/install, no
matter what python version is set as the default.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
app/cmdline_test/cmdline_test.py | 2 +-
app/cmdline_test/cmdline_test_data.py | 2 +-
app/test/autotest.py | 2 +-
app/test/autotest_data.py | 2 +-
app/test/autotest_runner.py | 2 +-
app/test/autotest_test_funcs.py | 2 +-
examples/ip_pipeline/config/diagram-generator.py | 2 +-
examples/ip_pipeline/config/pipeline-to-core-mapping.py | 2 +-
tools/cpu_layout.py | 2 +-
tools/dpdk-devbind.py | 2 +-
tools/dpdk-pmdinfo.py | 2 +-
11 files changed, 11 insertions(+), 11 deletions(-)
Comments
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Martin Kletzander
> Sent: Wednesday, December 7, 2016 10:17 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH] Force python scripts to run with python2
>
> With python3 being the default in some distributions/installations,
> shebang with just "python" will make the script run under version of
> python that the scripts are not written for. In order to fix that and
> mitigate future errors, use shebang properly and specify the python
> version. That way the scripts will run in any distro/install, no matter
> what python version is set as the default.
I think a better approach would be to make the scripts Python 2 and Python 3 compatible.
Some of the new ones already are.
2016-12-07 12:04, Mcnamara, John:
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Martin Kletzander
> > Sent: Wednesday, December 7, 2016 10:17 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH] Force python scripts to run with python2
> >
> > With python3 being the default in some distributions/installations,
> > shebang with just "python" will make the script run under version of
> > python that the scripts are not written for. In order to fix that and
> > mitigate future errors, use shebang properly and specify the python
> > version. That way the scripts will run in any distro/install, no matter
> > what python version is set as the default.
>
> I think a better approach would be to make the scripts Python 2 and Python 3 compatible.
>
> Some of the new ones already are.
Yes
The "solution" using python2 in the shebang does not work everywhere
because python2 can be an unknown command.
> -----Original Message-----
> From: Martin Kletzander [mailto:mkletzan@redhat.com]
> Sent: Thursday, December 8, 2016 8:40 AM
> To: Thomas Monjalon <thomas.monjalon@6wind.com>
> Cc: dev@dpdk.org; Mcnamara, John <john.mcnamara@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] Force python scripts to run with python2
>
> On Wed, Dec 07, 2016 at 03:48:37PM +0100, Thomas Monjalon wrote:
> >2016-12-07 12:04, Mcnamara, John:
> >> > -----Original Message-----
> >> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Martin
> >> > Kletzander
> >> > Sent: Wednesday, December 7, 2016 10:17 AM
> >> > To: dev@dpdk.org
> >> > Subject: [dpdk-dev] [PATCH] Force python scripts to run with
> >> > python2
> >> >
> >> > With python3 being the default in some distributions/installations,
> >> > shebang with just "python" will make the script run under version
> >> > of python that the scripts are not written for. In order to fix
> >> > that and mitigate future errors, use shebang properly and specify
> >> > the python version. That way the scripts will run in any
> >> > distro/install, no matter what python version is set as the default.
> >>
> >> I think a better approach would be to make the scripts Python 2 and
> Python 3 compatible.
> >>
> >> Some of the new ones already are.
> >
> >Yes
> >
> >The "solution" using python2 in the shebang does not work everywhere
> >because python2 can be an unknown command.
>
> I have not come across a system that would not have python2 as at least a
> symlink or an executable. However if that is the concern, I can have a
> look at making all scripts python3 compatible, although I'm not yet
> familiar enough with DPDK to be able to properly test all of them. So
> I'll try and ask if needed.
>
> Thanks for the input.
>
Hi Martin,
I'll work on adding Python2/3 compatibility, and while I'm at it PEP8 compatibility.
John
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python2
#
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python2
#
# BSD LICENSE
#
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# -------------------------------------------------------------------------
#
# Utility to dump PMD_INFO_STRING support from an object file