integrate coding style checks in setup.py
authorAndrea Righi <andrea.righi@canonical.com>
Fri, 16 Jun 2023 06:09:54 +0000 (08:09 +0200)
committerAndrea Righi <andrea.righi@canonical.com>
Fri, 16 Jun 2023 10:10:09 +0000 (12:10 +0200)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Makefile [deleted file]
setup.py

diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index 5ccbbd1..0000000
--- a/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-.PHONY: all lint flake8 pylint
-
-all:  lint
-
-lint: flake8 pylint
-
-flake8:
-       flake8 bin/sanitize-annotations kconfig/run.py kconfig/annotations.py kconfig/version.py .
-
-pylint:
-       pylint bin/sanitize-annotations kconfig
index 85fc90370e4b45e0635094096ae7d65ca8256c29..cbd0d7103a6918d9e94bcc5fe58f6096ca30cd86 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -2,15 +2,27 @@
 
 import os
 import subprocess
-from setuptools import setup
+from glob import glob
+from setuptools import setup, Command
 from kconfig.version import VERSION
-from setuptools.command.build_py import build_py
 
 
-class BuildPy(build_py):
+class LintCommand(Command):
+    description = "Run coding style checks"
+    user_options = []
+
+    def initialize_options(self):
+        pass
+
+    def finalize_options(self):
+        pass
+
     def run(self):
-        subprocess.check_call(["make"])
-        build_py.run(self)
+        for cmd in ("flake8", "pylint"):
+            command = [cmd]
+            for pattern in ("*.py", "kconfig/*.py", "bin/*"):
+                command += glob(pattern)
+            subprocess.call(command)
 
 
 setup(
@@ -21,8 +33,10 @@ setup(
     description="Manage Ubuntu kernel .config",
     url="https://git.launchpad.net/~arighi/+git/annotations-tools",
     license="GPLv2",
-    long_description=open(
-        os.path.join(os.path.dirname(__file__), "README.rst"), "r"
+    long_description=open(  # pylint: disable=consider-using-with
+        os.path.join(os.path.dirname(__file__), "README.rst"),
+        "r",
+        encoding="utf-8",
     ).read(),
     long_description_content_type="text/x-rts",
     packages=["kconfig"],
@@ -33,7 +47,7 @@ setup(
         ]
     },
     cmdclass={
-        "build_py": BuildPy,
+        "lint": LintCommand,
     },
     scripts=[
         "bin/sanitize-annotations",