DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] Force python scripts to run with python2
@ 2016-12-07 10:16 Martin Kletzander
  2016-12-07 12:04 ` Mcnamara, John
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Kletzander @ 2016-12-07 10:16 UTC (permalink / raw)
  To: dev

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(-)

diff --git a/app/cmdline_test/cmdline_test.py b/app/cmdline_test/cmdline_test.py
index 8efc5ead4439..3a3937abc8fb 100755
--- a/app/cmdline_test/cmdline_test.py
+++ b/app/cmdline_test/cmdline_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/app/cmdline_test/cmdline_test_data.py b/app/cmdline_test/cmdline_test_data.py
index b1945a579f24..882b7355f83d 100644
--- a/app/cmdline_test/cmdline_test_data.py
+++ b/app/cmdline_test/cmdline_test_data.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/app/test/autotest.py b/app/test/autotest.py
index b9fd6b6f5b21..4891410dbbd6 100644
--- a/app/test/autotest.py
+++ b/app/test/autotest.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/app/test/autotest_data.py b/app/test/autotest_data.py
index 9e8fd946a063..6e84eccc6a2e 100644
--- a/app/test/autotest_data.py
+++ b/app/test/autotest_data.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/app/test/autotest_runner.py b/app/test/autotest_runner.py
index 21d3be2cb2cd..1eb64d3bedd5 100644
--- a/app/test/autotest_runner.py
+++ b/app/test/autotest_runner.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/app/test/autotest_test_funcs.py b/app/test/autotest_test_funcs.py
index 14cffd014565..8ee9b280706b 100644
--- a/app/test/autotest_test_funcs.py
+++ b/app/test/autotest_test_funcs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/examples/ip_pipeline/config/diagram-generator.py b/examples/ip_pipeline/config/diagram-generator.py
index 6b7170b00486..7a2eb3fd6319 100755
--- a/examples/ip_pipeline/config/diagram-generator.py
+++ b/examples/ip_pipeline/config/diagram-generator.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/examples/ip_pipeline/config/pipeline-to-core-mapping.py b/examples/ip_pipeline/config/pipeline-to-core-mapping.py
index c2050b82a9fb..355061405d9d 100755
--- a/examples/ip_pipeline/config/pipeline-to-core-mapping.py
+++ b/examples/ip_pipeline/config/pipeline-to-core-mapping.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2

 #   BSD LICENSE
 #
diff --git a/tools/cpu_layout.py b/tools/cpu_layout.py
index d38d0b5a0cfe..97038b37aa28 100755
--- a/tools/cpu_layout.py
+++ b/tools/cpu_layout.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python2
 #
 #   BSD LICENSE
 #
diff --git a/tools/dpdk-devbind.py b/tools/dpdk-devbind.py
index f1d374d6b08c..f520f9a99d5b 100755
--- a/tools/dpdk-devbind.py
+++ b/tools/dpdk-devbind.py
@@ -1,4 +1,4 @@
-#! /usr/bin/python
+#!/usr/bin/env python2
 #
 #   BSD LICENSE
 #
diff --git a/tools/dpdk-pmdinfo.py b/tools/dpdk-pmdinfo.py
index 3db9819c61d3..0a8fba01f0ff 100755
--- a/tools/dpdk-pmdinfo.py
+++ b/tools/dpdk-pmdinfo.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
 # -------------------------------------------------------------------------
 #
 # Utility to dump PMD_INFO_STRING support from an object file
-- 
2.11.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] Force python scripts to run with python2
  2016-12-07 10:16 [dpdk-dev] [PATCH] Force python scripts to run with python2 Martin Kletzander
@ 2016-12-07 12:04 ` Mcnamara, John
  2016-12-07 14:48   ` Thomas Monjalon
  0 siblings, 1 reply; 4+ messages in thread
From: Mcnamara, John @ 2016-12-07 12:04 UTC (permalink / raw)
  To: Martin Kletzander, dev

> -----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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] Force python scripts to run with python2
  2016-12-07 12:04 ` Mcnamara, John
@ 2016-12-07 14:48   ` Thomas Monjalon
       [not found]     ` <20161208083941.GA20753@wheatley>
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Monjalon @ 2016-12-07 14:48 UTC (permalink / raw)
  To: Martin Kletzander; +Cc: dev, Mcnamara, John

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] Force python scripts to run with python2
       [not found]     ` <20161208083941.GA20753@wheatley>
@ 2016-12-08  9:07       ` Mcnamara, John
  0 siblings, 0 replies; 4+ messages in thread
From: Mcnamara, John @ 2016-12-08  9:07 UTC (permalink / raw)
  To: Martin Kletzander, Thomas Monjalon; +Cc: dev

> -----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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-08  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-07 10:16 [dpdk-dev] [PATCH] Force python scripts to run with python2 Martin Kletzander
2016-12-07 12:04 ` Mcnamara, John
2016-12-07 14:48   ` Thomas Monjalon
     [not found]     ` <20161208083941.GA20753@wheatley>
2016-12-08  9:07       ` Mcnamara, John

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).