From 576772cb8b01a55e60ba1e4eb9ef9deaf879c9ce Mon Sep 17 00:00:00 2001 From: Andrea Righi Date: Fri, 16 Jun 2023 08:09:54 +0200 Subject: [PATCH] integrate coding style checks in setup.py Signed-off-by: Andrea Righi --- Makefile | 11 ----------- setup.py | 30 ++++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 19 deletions(-) delete mode 100644 Makefile diff --git a/Makefile b/Makefile deleted file mode 100644 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 diff --git a/setup.py b/setup.py index 85fc903..cbd0d71 100755 --- 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", -- 2.31.1