All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8
@ 2020-08-12 14:28 Thomas Petazzoni
  2020-08-12 14:28 ` [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile Thomas Petazzoni
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:28 UTC (permalink / raw)
  To: buildroot

Hello,

Now that we are using the "async" keyword and related Python 3.x
functionality in support/scripts/pkg-stats, our check-flake8 Gitlab CI
job no longer passes:

  https://gitlab.com/buildroot.org/buildroot/-/jobs/681711009

It borks on the "async" keyword. The purpose of this series is to
switch to using the Python 3.x flake8.

Patches 1 to 5 fix existing issues in our Python codebase which were
accepted by the Python 2.x flake8, but not the Python 3.x flake8.

Patch 6 changes our Dockerfile to install python3-flake8 instead of
python-flake8, and patch 7 changes our Gitlab CI job to use the
Python3 flake8 checker.

Once patch 6 is applied, someone will have to rebuild and upload the
Docker image that Buildroot's Gitlab CI is using, and re-adjust patch
7 before applying it to use the new Docker image.

Thanks,

Thomas

Thomas Petazzoni (7):
  utils/{check-package,checkpackagelib}: consistently use raw strings
    for re.compile
  support/testing: consistently use raw strings for re.compile
  support/testing/tests/core/test_timezone.py: fix indentation
  utils/getdeveloperlib.py: use raw strings for re.compile/re.match
  utils/scanpypi: use raw strings in re.compile/re.sub
  support/docker: use python3-flake8
  support/misc/gitlab-ci.yml.in: use python3 for flake8

 support/docker/Dockerfile                   |  2 +-
 support/misc/gitlab-ci.yml.in               |  2 +-
 support/testing/infra/__init__.py           |  4 +-
 support/testing/tests/core/test_timezone.py |  8 +--
 utils/check-package                         | 34 ++++++------
 utils/checkpackagelib/lib_config.py         |  4 +-
 utils/checkpackagelib/lib_mk.py             | 60 ++++++++++-----------
 utils/checkpackagelib/lib_patch.py          |  6 +--
 utils/getdeveloperlib.py                    | 10 ++--
 utils/scanpypi                              |  8 +--
 10 files changed, 69 insertions(+), 69 deletions(-)

-- 
2.26.2

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

* [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
@ 2020-08-12 14:28 ` Thomas Petazzoni
  2020-08-13 22:09   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 2/7] support/testing: " Thomas Petazzoni
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:28 UTC (permalink / raw)
  To: buildroot

Raw strings need to be used when calling re.compile() otherwise Python
3.x flake8 complains with:

W605 invalid escape sequence '\s'

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 utils/check-package                 | 34 ++++++++--------
 utils/checkpackagelib/lib_config.py |  4 +-
 utils/checkpackagelib/lib_mk.py     | 60 ++++++++++++++---------------
 utils/checkpackagelib/lib_patch.py  |  6 +--
 4 files changed, 52 insertions(+), 52 deletions(-)

diff --git a/utils/check-package b/utils/check-package
index 52317e02f4..dd18d19c25 100755
--- a/utils/check-package
+++ b/utils/check-package
@@ -46,24 +46,24 @@ def parse_args():
     return parser.parse_args()
 
 
-CONFIG_IN_FILENAME = re.compile("Config\.\S*$")
-DO_CHECK_INTREE = re.compile("|".join([
-    "Config.in",
-    "arch/",
-    "boot/",
-    "fs/",
-    "linux/",
-    "package/",
-    "system/",
-    "toolchain/",
+CONFIG_IN_FILENAME = re.compile(r"Config\.\S*$")
+DO_CHECK_INTREE = re.compile(r"|".join([
+    r"Config.in",
+    r"arch/",
+    r"boot/",
+    r"fs/",
+    r"linux/",
+    r"package/",
+    r"system/",
+    r"toolchain/",
     ]))
-DO_NOT_CHECK_INTREE = re.compile("|".join([
-    "boot/barebox/barebox\.mk$",
-    "fs/common\.mk$",
-    "package/doc-asciidoc\.mk$",
-    "package/pkg-\S*\.mk$",
-    "toolchain/helpers\.mk$",
-    "toolchain/toolchain-external/pkg-toolchain-external\.mk$",
+DO_NOT_CHECK_INTREE = re.compile(r"|".join([
+    r"boot/barebox/barebox\.mk$",
+    r"fs/common\.mk$",
+    r"package/doc-asciidoc\.mk$",
+    r"package/pkg-\S*\.mk$",
+    r"toolchain/helpers\.mk$",
+    r"toolchain/toolchain-external/pkg-toolchain-external\.mk$",
     ]))
 
 
diff --git a/utils/checkpackagelib/lib_config.py b/utils/checkpackagelib/lib_config.py
index 55c8589d71..c348eec399 100644
--- a/utils/checkpackagelib/lib_config.py
+++ b/utils/checkpackagelib/lib_config.py
@@ -152,8 +152,8 @@ class CommentsMenusPackagesOrder(_CheckFunction):
 
 
 class HelpText(_CheckFunction):
-    HELP_TEXT_FORMAT = re.compile("^\t  .{,62}$")
-    URL_ONLY = re.compile("^(http|https|git)://\S*$")
+    HELP_TEXT_FORMAT = re.compile(r"^\t  .{,62}$")
+    URL_ONLY = re.compile(r"^(http|https|git)://\S*$")
 
     def before(self):
         self.help_text = False
diff --git a/utils/checkpackagelib/lib_mk.py b/utils/checkpackagelib/lib_mk.py
index a0caf84636..45e37e4598 100644
--- a/utils/checkpackagelib/lib_mk.py
+++ b/utils/checkpackagelib/lib_mk.py
@@ -20,12 +20,12 @@ end_conditional = ["endif"]
 
 
 class Indent(_CheckFunction):
-    COMMENT = re.compile("^\s*#")
-    CONDITIONAL = re.compile("^\s*({})\s".format("|".join(start_conditional + end_conditional)))
+    COMMENT = re.compile(r"^\s*#")
+    CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional)))
     ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$")
-    END_DEFINE = re.compile("^\s*endef\s")
-    MAKEFILE_TARGET = re.compile("^[^# \t]+:\s")
-    START_DEFINE = re.compile("^\s*define\s")
+    END_DEFINE = re.compile(r"^\s*endef\s")
+    MAKEFILE_TARGET = re.compile(r"^[^# \t]+:\s")
+    START_DEFINE = re.compile(r"^\s*define\s")
 
     def before(self):
         self.define = False
@@ -76,17 +76,17 @@ class Indent(_CheckFunction):
 
 
 class OverriddenVariable(_CheckFunction):
-    CONCATENATING = re.compile("^([A-Z0-9_]+)\s*(\+|:|)=\s*\$\(\\1\)")
-    END_CONDITIONAL = re.compile("^\s*({})".format("|".join(end_conditional)))
+    CONCATENATING = re.compile(r"^([A-Z0-9_]+)\s*(\+|:|)=\s*\$\(\\1\)")
+    END_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(end_conditional)))
     OVERRIDING_ASSIGNMENTS = [':=', "="]
-    START_CONDITIONAL = re.compile("^\s*({})".format("|".join(start_conditional)))
-    VARIABLE = re.compile("^([A-Z0-9_]+)\s*((\+|:|)=)")
-    USUALLY_OVERRIDDEN = re.compile("^[A-Z0-9_]+({})".format("|".join([
-        "_ARCH\s*=\s*",
-        "_CPU\s*=\s*",
-        "_SITE\s*=\s*",
-        "_SOURCE\s*=\s*",
-        "_VERSION\s*=\s*"])))
+    START_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(start_conditional)))
+    VARIABLE = re.compile(r"^([A-Z0-9_]+)\s*((\+|:|)=)")
+    USUALLY_OVERRIDDEN = re.compile(r"^[A-Z0-9_]+({})".format("|".join([
+        r"_ARCH\s*=\s*",
+        r"_CPU\s*=\s*",
+        r"_SITE\s*=\s*",
+        r"_SOURCE\s*=\s*",
+        r"_VERSION\s*=\s*"])))
 
     def before(self):
         self.conditional = 0
@@ -174,7 +174,7 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
         package_upper = package.replace("-", "_").upper()
         self.package = package
         self.FIND_SOURCE = re.compile(
-            "^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
+            r"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
             .format(package_upper, package, package_upper))
 
     def check_line(self, lineno, text):
@@ -222,7 +222,7 @@ class TrailingBackslash(_CheckFunction):
 
 
 class TypoInPackageVariable(_CheckFunction):
-    ALLOWED = re.compile("|".join([
+    ALLOWED = re.compile(r"|".join([
         "ACLOCAL_DIR",
         "ACLOCAL_HOST_DIR",
         "ACLOCAL_PATH",
@@ -241,7 +241,7 @@ class TypoInPackageVariable(_CheckFunction):
         "TARGET_FINALIZE_HOOKS",
         "TARGETS_ROOTFS",
         "XTENSA_CORE_NAME"]))
-    VARIABLE = re.compile("^([A-Z0-9_]+_[A-Z0-9_]+)\s*(\+|)=")
+    VARIABLE = re.compile(r"^([A-Z0-9_]+_[A-Z0-9_]+)\s*(\+|)=")
 
     def before(self):
         package, _ = os.path.splitext(os.path.basename(self.filename))
@@ -251,9 +251,9 @@ class TypoInPackageVariable(_CheckFunction):
         # linux extensions do not use LINUX_EXT_ prefix for variables
         package = package.replace("LINUX_EXT_", "")
         self.package = package
-        self.REGEX = re.compile("^(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
+        self.REGEX = re.compile(r"^(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
         self.FIND_VIRTUAL = re.compile(
-            "^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
+            r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
         self.virtual = []
 
     def check_line(self, lineno, text):
@@ -281,16 +281,16 @@ class TypoInPackageVariable(_CheckFunction):
 
 
 class UselessFlag(_CheckFunction):
-    DEFAULT_AUTOTOOLS_FLAG = re.compile("^.*{}".format("|".join([
-        "_AUTORECONF\s*=\s*NO",
-        "_LIBTOOL_PATCH\s*=\s*YES"])))
-    DEFAULT_GENERIC_FLAG = re.compile("^.*{}".format("|".join([
-        "_INSTALL_IMAGES\s*=\s*NO",
-        "_INSTALL_REDISTRIBUTE\s*=\s*YES",
-        "_INSTALL_STAGING\s*=\s*NO",
-        "_INSTALL_TARGET\s*=\s*YES"])))
-    END_CONDITIONAL = re.compile("^\s*({})".format("|".join(end_conditional)))
-    START_CONDITIONAL = re.compile("^\s*({})".format("|".join(start_conditional)))
+    DEFAULT_AUTOTOOLS_FLAG = re.compile(r"^.*{}".format("|".join([
+        r"_AUTORECONF\s*=\s*NO",
+        r"_LIBTOOL_PATCH\s*=\s*YES"])))
+    DEFAULT_GENERIC_FLAG = re.compile(r"^.*{}".format("|".join([
+        r"_INSTALL_IMAGES\s*=\s*NO",
+        r"_INSTALL_REDISTRIBUTE\s*=\s*YES",
+        r"_INSTALL_STAGING\s*=\s*NO",
+        r"_INSTALL_TARGET\s*=\s*YES"])))
+    END_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(end_conditional)))
+    START_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(start_conditional)))
 
     def before(self):
         self.conditional = 0
diff --git a/utils/checkpackagelib/lib_patch.py b/utils/checkpackagelib/lib_patch.py
index 438353ad3b..e4e914b7f0 100644
--- a/utils/checkpackagelib/lib_patch.py
+++ b/utils/checkpackagelib/lib_patch.py
@@ -11,7 +11,7 @@ from checkpackagelib.lib import NewlineAtEof           # noqa: F401
 
 
 class ApplyOrder(_CheckFunction):
-    APPLY_ORDER = re.compile("\d{1,4}-[^/]*$")
+    APPLY_ORDER = re.compile(r"\d{1,4}-[^/]*$")
 
     def before(self):
         if not self.APPLY_ORDER.match(os.path.basename(self.filename)):
@@ -21,7 +21,7 @@ class ApplyOrder(_CheckFunction):
 
 
 class NumberedSubject(_CheckFunction):
-    NUMBERED_PATCH = re.compile("Subject:\s*\[PATCH\s*\d+/\d+\]")
+    NUMBERED_PATCH = re.compile(r"Subject:\s*\[PATCH\s*\d+/\d+\]")
 
     def before(self):
         self.git_patch = False
@@ -44,7 +44,7 @@ class NumberedSubject(_CheckFunction):
 
 
 class Sob(_CheckFunction):
-    SOB_ENTRY = re.compile("^Signed-off-by: .*$")
+    SOB_ENTRY = re.compile(r"^Signed-off-by: .*$")
 
     def before(self):
         self.found = False
-- 
2.26.2

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

* [Buildroot] [PATCH 2/7] support/testing: consistently use raw strings for re.compile
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
  2020-08-12 14:28 ` [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:10   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation Thomas Petazzoni
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

Otherwise Python 3.x flake8 complains with:

W605 invalid escape sequence '\s'

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/testing/infra/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/support/testing/infra/__init__.py b/support/testing/infra/__init__.py
index 6392aa679b..6522a265f3 100644
--- a/support/testing/infra/__init__.py
+++ b/support/testing/infra/__init__.py
@@ -78,7 +78,7 @@ def get_elf_arch_tag(builddir, prefix, fpath, tag):
     cmd = ["host/bin/{}-readelf".format(prefix),
            "-A", os.path.join("target", fpath)]
     out = run_cmd_on_host(builddir, cmd)
-    regexp = re.compile("^  {}: (.*)$".format(tag))
+    regexp = re.compile(r"^  {}: (.*)$".format(tag))
     for line in out.splitlines():
         m = regexp.match(line)
         if not m:
@@ -105,7 +105,7 @@ def get_elf_prog_interpreter(builddir, prefix, fpath):
     cmd = ["host/bin/{}-readelf".format(prefix),
            "-l", os.path.join("target", fpath)]
     out = run_cmd_on_host(builddir, cmd)
-    regexp = re.compile("^ *\[Requesting program interpreter: (.*)\]$")
+    regexp = re.compile(r"^ *\[Requesting program interpreter: (.*)\]$")
     for line in out.splitlines():
         m = regexp.match(line)
         if not m:
-- 
2.26.2

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

* [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
  2020-08-12 14:28 ` [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile Thomas Petazzoni
  2020-08-12 14:29 ` [Buildroot] [PATCH 2/7] support/testing: " Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:14   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match Thomas Petazzoni
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

Fixes:

support/testing/tests/core/test_timezone.py:7:9: E117 over-indented

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/testing/tests/core/test_timezone.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/support/testing/tests/core/test_timezone.py b/support/testing/tests/core/test_timezone.py
index 050624e0aa..f661519196 100644
--- a/support/testing/tests/core/test_timezone.py
+++ b/support/testing/tests/core/test_timezone.py
@@ -4,10 +4,10 @@ import infra.basetest
 
 
 def boot_armv5_cpio(emulator, builddir):
-        img = os.path.join(builddir, "images", "rootfs.cpio")
-        emulator.boot(arch="armv5", kernel="builtin",
-                      options=["-initrd", img])
-        emulator.login()
+    img = os.path.join(builddir, "images", "rootfs.cpio")
+    emulator.boot(arch="armv5", kernel="builtin",
+                  options=["-initrd", img])
+    emulator.login()
 
 
 class TestNoTimezone(infra.basetest.BRTest):
-- 
2.26.2

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

* [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
                   ` (2 preceding siblings ...)
  2020-08-12 14:29 ` [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:14   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub Thomas Petazzoni
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

Fixes the following Python 3.x flake8 warning:

W605 invalid escape sequence '\s'

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 utils/getdeveloperlib.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/utils/getdeveloperlib.py b/utils/getdeveloperlib.py
index 239ffa340b..dc0cc07cc7 100644
--- a/utils/getdeveloperlib.py
+++ b/utils/getdeveloperlib.py
@@ -10,7 +10,7 @@ import unittest
 # Patch parsing functions
 #
 
-FIND_INFRA_IN_PATCH = re.compile("^\+\$\(eval \$\((host-)?([^-]*)-package\)\)$")
+FIND_INFRA_IN_PATCH = re.compile(r"^\+\$\(eval \$\((host-)?([^-]*)-package\)\)$")
 
 
 def analyze_patch(patch):
@@ -33,7 +33,7 @@ def analyze_patch(patch):
     return (files, infras)
 
 
-FIND_INFRA_IN_MK = re.compile("^\$\(eval \$\((host-)?([^-]*)-package\)\)$")
+FIND_INFRA_IN_MK = re.compile(r"^\$\(eval \$\((host-)?([^-]*)-package\)\)$")
 
 
 def fname_get_package_infra(fname):
@@ -178,7 +178,7 @@ def parse_arches_from_config_in(fname):
                 parsing_arches = True
                 continue
             if parsing_arches:
-                m = re.match("^\s*default \"([^\"]*)\".*", line)
+                m = re.match(r"^\s*default \"([^\"]*)\".*", line)
                 if m:
                     arches.add(m.group(1))
                 else:
@@ -192,7 +192,7 @@ def parse_developer_architectures(fnames):
     developer is working on."""
     arches = set()
     for fname in fnames:
-        if not re.match("^.*/arch/Config\.in\..*$", fname):
+        if not re.match(r"^.*/arch/Config\.in\..*$", fname):
             continue
         arches = arches | parse_arches_from_config_in(fname)
     return arches
@@ -201,7 +201,7 @@ def parse_developer_architectures(fnames):
 def parse_developer_infras(fnames):
     infras = set()
     for fname in fnames:
-        m = re.match("^package/pkg-([^.]*).mk$", fname)
+        m = re.match(r"^package/pkg-([^.]*).mk$", fname)
         if m:
             infras.add(m.group(1))
     return infras
-- 
2.26.2

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

* [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
                   ` (3 preceding siblings ...)
  2020-08-12 14:29 ` [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:15   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 6/7] support/docker: use python3-flake8 Thomas Petazzoni
  2020-08-12 14:29 ` [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8 Thomas Petazzoni
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

Fixes the following Python 3.x flake8 warning:

W605 invalid escape sequence '\w'

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 utils/scanpypi | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/utils/scanpypi b/utils/scanpypi
index 212dbea85e..51bc249f9e 100755
--- a/utils/scanpypi
+++ b/utils/scanpypi
@@ -96,10 +96,10 @@ def pkg_buildroot_name(pkg_name):
     Keyword arguments:
     pkg_name -- String to rename
     """
-    name = re.sub('[^\w-]', '', pkg_name.lower())
+    name = re.sub(r'[^\w-]', '', pkg_name.lower())
     name = name.replace('_', '-')
     prefix = 'python-'
-    pattern = re.compile('^(?!' + prefix + ')(.+?)$')
+    pattern = re.compile(r'^(?!' + prefix + ')(.+?)$')
     name = pattern.sub(r'python-\1', name)
     return name
 
@@ -337,7 +337,7 @@ class BuildrootPackage():
             self.pkg_req = None
             return set()
         self.pkg_req = self.setup_metadata['install_requires']
-        self.pkg_req = [re.sub('([-.\w]+).*', r'\1', req)
+        self.pkg_req = [re.sub(r'([-.\w]+).*', r'\1', req)
                         for req in self.pkg_req]
 
         # get rid of commented lines and also strip the package strings
@@ -451,7 +451,7 @@ class BuildrootPackage():
                 "Mozilla Public License 2.0": "MPL-2.0",
                 "Zope Public License": "ZPL"
                 }
-            regexp = re.compile('^License :* *.* *:+ (.*)( \(.*\))?$')
+            regexp = re.compile(r'^License :* *.* *:+ (.*)( \(.*\))?$')
             classifiers_licenses = [regexp.sub(r"\1", lic)
                                     for lic in self.metadata['info']['classifiers']
                                     if regexp.match(lic)]
-- 
2.26.2

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

* [Buildroot] [PATCH 6/7] support/docker: use python3-flake8
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
                   ` (4 preceding siblings ...)
  2020-08-12 14:29 ` [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:20   ` Titouan Christophe
  2020-08-12 14:29 ` [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8 Thomas Petazzoni
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

support/scripts/pkg-stats now uses some Python 3.x only constructs
("async" and related keywords), so we must use the Python 3.x flake8.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/docker/Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/docker/Dockerfile b/support/docker/Dockerfile
index 03acde85d2..8c555dcf7a 100644
--- a/support/docker/Dockerfile
+++ b/support/docker/Dockerfile
@@ -36,10 +36,10 @@ RUN apt-get install -y --no-install-recommends \
         libncurses5-dev \
         locales \
         mercurial \
-        python-flake8 \
         python-nose2 \
         python-pexpect \
         python3 \
+        python3-flake8 \
         python3-nose2 \
         python3-pexpect \
         qemu-system-arm \
-- 
2.26.2

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

* [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8
  2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
                   ` (5 preceding siblings ...)
  2020-08-12 14:29 ` [Buildroot] [PATCH 6/7] support/docker: use python3-flake8 Thomas Petazzoni
@ 2020-08-12 14:29 ` Thomas Petazzoni
  2020-08-13 22:23   ` Titouan Christophe
  6 siblings, 1 reply; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-12 14:29 UTC (permalink / raw)
  To: buildroot

The pkg-stats script now uses Python3 only constructs (the "async"
keyword) and therefore fails to pass the Python2 flake8 test.

Let's use the Python3 flake8 instead.

Fixes:

  https://gitlab.com/buildroot.org/buildroot/-/jobs/681711009

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 support/misc/gitlab-ci.yml.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/support/misc/gitlab-ci.yml.in b/support/misc/gitlab-ci.yml.in
index 7218ea027e..75ffaab8fe 100644
--- a/support/misc/gitlab-ci.yml.in
+++ b/support/misc/gitlab-ci.yml.in
@@ -25,7 +25,7 @@ check-flake8:
         - find * -type f -print0 | xargs -0 file | grep 'Python script' | cut -d':' -f1 >> files.txt
         - sort -u files.txt | tee files.processed
     script:
-        - python -m flake8 --statistics --count --max-line-length=132 $(cat files.processed)
+        - python3 -m flake8 --statistics --count --max-line-length=132 $(cat files.processed)
     after_script:
         - wc -l files.processed
 
-- 
2.26.2

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

* [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile
  2020-08-12 14:28 ` [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile Thomas Petazzoni
@ 2020-08-13 22:09   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:09 UTC (permalink / raw)
  To: buildroot

Hi Thomas and all,

On 12/08/20 16:28, Thomas Petazzoni wrote:
> Raw strings need to be used when calling re.compile() otherwise Python
> 3.x flake8 complains with:
> 
> W605 invalid escape sequence '\s'
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 2/7] support/testing: consistently use raw strings for re.compile
  2020-08-12 14:29 ` [Buildroot] [PATCH 2/7] support/testing: " Thomas Petazzoni
@ 2020-08-13 22:10   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:10 UTC (permalink / raw)
  To: buildroot

Hello Thomas and all,

On 12/08/20 16:29, Thomas Petazzoni wrote:
> Otherwise Python 3.x flake8 complains with:
> 
> W605 invalid escape sequence '\s'
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation
  2020-08-12 14:29 ` [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation Thomas Petazzoni
@ 2020-08-13 22:14   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:14 UTC (permalink / raw)
  To: buildroot

Hello Thomas, all

On 12/08/20 16:29, Thomas Petazzoni wrote:
> Fixes:
> 
> support/testing/tests/core/test_timezone.py:7:9: E117 over-indented
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match
  2020-08-12 14:29 ` [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match Thomas Petazzoni
@ 2020-08-13 22:14   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:14 UTC (permalink / raw)
  To: buildroot

Hello,

On 12/08/20 16:29, Thomas Petazzoni wrote:
> Fixes the following Python 3.x flake8 warning:
> 
> W605 invalid escape sequence '\s'
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub
  2020-08-12 14:29 ` [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub Thomas Petazzoni
@ 2020-08-13 22:15   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:15 UTC (permalink / raw)
  To: buildroot

Hello,

On 12/08/20 16:29, Thomas Petazzoni wrote:
> Fixes the following Python 3.x flake8 warning:
> 
> W605 invalid escape sequence '\w'
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 6/7] support/docker: use python3-flake8
  2020-08-12 14:29 ` [Buildroot] [PATCH 6/7] support/docker: use python3-flake8 Thomas Petazzoni
@ 2020-08-13 22:20   ` Titouan Christophe
  2020-08-14 19:39     ` Thomas Petazzoni
  0 siblings, 1 reply; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:20 UTC (permalink / raw)
  To: buildroot

Hello Thomas,

On 12/08/20 16:29, Thomas Petazzoni wrote:
> support/scripts/pkg-stats now uses some Python 3.x only constructs
> ("async" and related keywords), so we must use the Python 3.x flake8.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> ---
>   support/docker/Dockerfile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/support/docker/Dockerfile b/support/docker/Dockerfile
> index 03acde85d2..8c555dcf7a 100644
> --- a/support/docker/Dockerfile
> +++ b/support/docker/Dockerfile
> @@ -36,10 +36,10 @@ RUN apt-get install -y --no-install-recommends \
>           libncurses5-dev \
>           locales \
>           mercurial \
> -        python-flake8 \
>           python-nose2 \
>           python-pexpect \

Out of curiosity, why keeping the py2 packages here ? Couldn't all the 
scripts be run in python3 now ?

>           python3 \
> +        python3-flake8 \
>           python3-nose2 \
>           python3-pexpect \
>           qemu-system-arm \
> 

Kind regards,

Titouan

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

* [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8
  2020-08-12 14:29 ` [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8 Thomas Petazzoni
@ 2020-08-13 22:23   ` Titouan Christophe
  0 siblings, 0 replies; 16+ messages in thread
From: Titouan Christophe @ 2020-08-13 22:23 UTC (permalink / raw)
  To: buildroot

Hello,

On 12/08/20 16:29, Thomas Petazzoni wrote:
> The pkg-stats script now uses Python3 only constructs (the "async"
> keyword) and therefore fails to pass the Python2 flake8 test.
> 
> Let's use the Python3 flake8 instead.
> 
> Fixes:
> 
>    https://gitlab.com/buildroot.org/buildroot/-/jobs/681711009
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>

Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu>

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

* [Buildroot] [PATCH 6/7] support/docker: use python3-flake8
  2020-08-13 22:20   ` Titouan Christophe
@ 2020-08-14 19:39     ` Thomas Petazzoni
  0 siblings, 0 replies; 16+ messages in thread
From: Thomas Petazzoni @ 2020-08-14 19:39 UTC (permalink / raw)
  To: buildroot

On Fri, 14 Aug 2020 00:20:18 +0200
Titouan Christophe <titouan.christophe@railnova.eu> wrote:

> > diff --git a/support/docker/Dockerfile b/support/docker/Dockerfile
> > index 03acde85d2..8c555dcf7a 100644
> > --- a/support/docker/Dockerfile
> > +++ b/support/docker/Dockerfile
> > @@ -36,10 +36,10 @@ RUN apt-get install -y --no-install-recommends \
> >           libncurses5-dev \
> >           locales \
> >           mercurial \
> > -        python-flake8 \
> >           python-nose2 \
> >           python-pexpect \  
> 
> Out of curiosity, why keeping the py2 packages here ? Couldn't all the 
> scripts be run in python3 now ?

The runtime test infrastructure is using Python 3.x nowadays, so I
think we could drop those Python 2.x dependencies.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

end of thread, other threads:[~2020-08-14 19:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 14:28 [Buildroot] [PATCH 0/7] Switch to Python 3.x flake8 Thomas Petazzoni
2020-08-12 14:28 ` [Buildroot] [PATCH 1/7] utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile Thomas Petazzoni
2020-08-13 22:09   ` Titouan Christophe
2020-08-12 14:29 ` [Buildroot] [PATCH 2/7] support/testing: " Thomas Petazzoni
2020-08-13 22:10   ` Titouan Christophe
2020-08-12 14:29 ` [Buildroot] [PATCH 3/7] support/testing/tests/core/test_timezone.py: fix indentation Thomas Petazzoni
2020-08-13 22:14   ` Titouan Christophe
2020-08-12 14:29 ` [Buildroot] [PATCH 4/7] utils/getdeveloperlib.py: use raw strings for re.compile/re.match Thomas Petazzoni
2020-08-13 22:14   ` Titouan Christophe
2020-08-12 14:29 ` [Buildroot] [PATCH 5/7] utils/scanpypi: use raw strings in re.compile/re.sub Thomas Petazzoni
2020-08-13 22:15   ` Titouan Christophe
2020-08-12 14:29 ` [Buildroot] [PATCH 6/7] support/docker: use python3-flake8 Thomas Petazzoni
2020-08-13 22:20   ` Titouan Christophe
2020-08-14 19:39     ` Thomas Petazzoni
2020-08-12 14:29 ` [Buildroot] [PATCH 7/7] support/misc/gitlab-ci.yml.in: use python3 for flake8 Thomas Petazzoni
2020-08-13 22:23   ` Titouan Christophe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.