diff mbox series

[v2,1/4] support: utils: use python3 explicitly

Message ID 20210915194839.22122-2-petr.vorel@gmail.com
State Superseded
Headers show
Series use python3 explicitly | expand

Commit Message

Petr Vorel Sept. 15, 2021, 7:48 p.m. UTC
Python 2 is EOL sice 2020 [1], it's still available on distros, but may not
be installed by default (as being replaced by python3).

Thus remove compatibility imports:
from __future__ import print_function
from __future__ import absolute_import

Tested with python3 -m py_compile.

[1] https://www.python.org/doc/sunset-python-2/

Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
---
changes v1->v2:
* remove also python2 compatibility imports

 support/scripts/cve.py                                 | 2 +-
 support/scripts/graph-build-time                       | 2 +-
 support/scripts/graph-depends                          | 2 +-
 support/scripts/pycompile.py                           | 4 +---
 support/scripts/size-stats                             | 2 +-
 support/testing/tests/package/sample_gst1_python.py    | 2 +-
 support/testing/tests/package/sample_python_gobject.py | 2 +-
 utils/check-package                                    | 3 +--
 utils/genrandconfig                                    | 4 +---
 utils/get-developers                                   | 2 +-
 utils/size-stats-compare                               | 2 +-
 11 files changed, 11 insertions(+), 16 deletions(-)

Comments

Romain Naour Sept. 21, 2021, 8:20 p.m. UTC | #1
Hello Petr,

Le 15/09/2021 à 21:48, Petr Vorel a écrit :
> Python 2 is EOL sice 2020 [1], it's still available on distros, but may not
> be installed by default (as being replaced by python3).
> 
> Thus remove compatibility imports:
> from __future__ import print_function
> from __future__ import absolute_import
> 
> Tested with python3 -m py_compile.
> 
> [1] https://www.python.org/doc/sunset-python-2/
> 
> Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> ---

> diff --git a/utils/get-developers b/utils/get-developers
> index 9182b2d85f..22accaf181 100755
> --- a/utils/get-developers
> +++ b/utils/get-developers
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/env python3
>  
>  import argparse
>  import getdeveloperlib

There is one remaining __future__ to remove:

utils/getdeveloperlib.py:from __future__ import print_function

It was removed by your patch 3/4 but it was rejected:
http://patchwork.ozlabs.org/project/buildroot/patch/20210915194839.22122-4-petr.vorel@gmail.com/

Maybe it can be removed directly from this patch.

Best regards,
Romain


> diff --git a/utils/size-stats-compare b/utils/size-stats-compare
> index a3d7f250c6..422972e488 100755
> --- a/utils/size-stats-compare
> +++ b/utils/size-stats-compare
> @@ -1,4 +1,4 @@
> -#!/usr/bin/env python
> +#!/usr/bin/env python3
>  
>  # Copyright (C) 2016 Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
>  
>
Petr Vorel Sept. 21, 2021, 8:57 p.m. UTC | #2
Hi Romain,

> Hello Petr,

> Le 15/09/2021 à 21:48, Petr Vorel a écrit :
> > Python 2 is EOL sice 2020 [1], it's still available on distros, but may not
> > be installed by default (as being replaced by python3).

> > Thus remove compatibility imports:
> > from __future__ import print_function
> > from __future__ import absolute_import

> > Tested with python3 -m py_compile.

> > [1] https://www.python.org/doc/sunset-python-2/

> > Signed-off-by: Petr Vorel <petr.vorel@gmail.com>
> > ---

> > diff --git a/utils/get-developers b/utils/get-developers
> > index 9182b2d85f..22accaf181 100755
> > --- a/utils/get-developers
> > +++ b/utils/get-developers
> > @@ -1,4 +1,4 @@
> > -#!/usr/bin/env python
> > +#!/usr/bin/env python3

> >  import argparse
> >  import getdeveloperlib

> There is one remaining __future__ to remove:

> utils/getdeveloperlib.py:from __future__ import print_function
Thanks!

> It was removed by your patch 3/4 but it was rejected:
> http://patchwork.ozlabs.org/project/buildroot/patch/20210915194839.22122-4-petr.vorel@gmail.com/

I set it as rejected.

> Maybe it can be removed directly from this patch.
Nah, I can send v3 with this fixed.

> Best regards,
> Romain
diff mbox series

Patch

diff --git a/support/scripts/cve.py b/support/scripts/cve.py
index 13c29fabe0..7cd6fce4d8 100755
--- a/support/scripts/cve.py
+++ b/support/scripts/cve.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2009 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 # Copyright (C) 2020 by Gregory CLEMENT <gregory.clement@bootlin.com>
diff --git a/support/scripts/graph-build-time b/support/scripts/graph-build-time
index ba3cdad85b..742c9a7a50 100755
--- a/support/scripts/graph-build-time
+++ b/support/scripts/graph-build-time
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2011 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 # Copyright (C) 2013 by Yann E. MORIN <yann.morin.1998@free.fr>
diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends
index d42bebce9d..a66fb28f41 100755
--- a/support/scripts/graph-depends
+++ b/support/scripts/graph-depends
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Usage (the graphviz package must be installed in your distribution)
 #  ./support/scripts/graph-depends [-p package-name] > test.dot
diff --git a/support/scripts/pycompile.py b/support/scripts/pycompile.py
index b8cd3cee6c..8774144a90 100644
--- a/support/scripts/pycompile.py
+++ b/support/scripts/pycompile.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 """
 Byte compile all .py files from provided directories. This script is an
@@ -6,8 +6,6 @@  alternative implementation of compileall.compile_dir written with
 cross-compilation in mind.
 """
 
-from __future__ import print_function
-
 import argparse
 import os
 import py_compile
diff --git a/support/scripts/size-stats b/support/scripts/size-stats
index dea3a6007c..bf3d12a9b7 100755
--- a/support/scripts/size-stats
+++ b/support/scripts/size-stats
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2014 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 
diff --git a/support/testing/tests/package/sample_gst1_python.py b/support/testing/tests/package/sample_gst1_python.py
index fab7e74f40..2d7e0e1ed9 100644
--- a/support/testing/tests/package/sample_gst1_python.py
+++ b/support/testing/tests/package/sample_gst1_python.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """A simple test that uses gst1-python to run a fake videotestsrc for 100
 frames
 """
diff --git a/support/testing/tests/package/sample_python_gobject.py b/support/testing/tests/package/sample_python_gobject.py
index 50564aa79f..4490a73613 100644
--- a/support/testing/tests/package/sample_python_gobject.py
+++ b/support/testing/tests/package/sample_python_gobject.py
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """A simple test that uses python-gobject to find the path of sh."""
 from gi.repository import GLib
 
diff --git a/utils/check-package b/utils/check-package
index dd18d19c25..a959fef079 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -1,7 +1,6 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # See utils/checkpackagelib/readme.txt before editing this file.
 
-from __future__ import print_function
 import argparse
 import inspect
 import os
diff --git a/utils/genrandconfig b/utils/genrandconfig
index 622cfd4891..a1431bf1a8 100755
--- a/utils/genrandconfig
+++ b/utils/genrandconfig
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2014 by Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
 #
@@ -18,8 +18,6 @@ 
 
 # This script generates a random configuration for testing Buildroot.
 
-from __future__ import print_function
-
 import contextlib
 import csv
 import os
diff --git a/utils/get-developers b/utils/get-developers
index 9182b2d85f..22accaf181 100755
--- a/utils/get-developers
+++ b/utils/get-developers
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 import argparse
 import getdeveloperlib
diff --git a/utils/size-stats-compare b/utils/size-stats-compare
index a3d7f250c6..422972e488 100755
--- a/utils/size-stats-compare
+++ b/utils/size-stats-compare
@@ -1,4 +1,4 @@ 
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 # Copyright (C) 2016 Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>