From nobody Thu Dec 18 00:30:37 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678293605; cv=none; d=zohomail.com; s=zohoarc; b=mlFnf/LdbdhcwrvOZxmgebrIl9By5dWBKmgNhrkrEYTmLzNop8bW71TJxouWfQ+cPOqaNrJykvmqQmuOv6Eyn8IEg6sLyKXKtthPozOkpjyGkARe17CKDk1nLCFv8W/nHGFxD1Vk5PJwOT21jXgVTyBFrvMZRWxXcDodnZlNnDs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678293605; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xMM8Mtp1xaAzbqhW+dSzV8SkmByemWecEZPRgCy64ag=; b=XKFr4GggCHRnvDT6JNpLh5sO8MEyvfVByZyZh1K/hlT06/5G3GmmFD5/M9gBsIa9mUpCn7lgXkSbQPkrpa/DMVPvVA1vPgzl/2lnXeDZybFAFmp1AZR4ImNSsQ52scB+EXhag0zayAFzzGFWrgwc480vMlb0hkMV4m32lj0rqh4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1678293605204550.6871017826637; Wed, 8 Mar 2023 08:40:05 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-650-E8NqA5N4PaOvYUznDpeU6A-1; Wed, 08 Mar 2023 11:39:33 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C974100F909; Wed, 8 Mar 2023 16:39:22 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CAEE1121314; Wed, 8 Mar 2023 16:39:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 251181946A63; Wed, 8 Mar 2023 16:39:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 382DB19465B5 for ; Wed, 8 Mar 2023 16:39:18 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2A3801121330; Wed, 8 Mar 2023 16:39:18 +0000 (UTC) Received: from virtlab420.virt.lab.eng.bos.redhat.com (virtlab420.virt.lab.eng.bos.redhat.com [10.19.152.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 10366112132D; Wed, 8 Mar 2023 16:39:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678293604; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xMM8Mtp1xaAzbqhW+dSzV8SkmByemWecEZPRgCy64ag=; b=btVrLAE6qrhaP2tPadMWHg2mtuR5+RLaOe6xVlCOPRxLzCzFwsO0tTl9NkxebZibBXPyni jQyiwV3GLlP5dWVjSH5GAwy9tSEeSSOlBCIPRhBSNJhwlcWo/vE2tnG5MarnwLJh3lQdgr ChICLm1rQqJv9+clOkxvI7BjmCdzJYc= X-MC-Unique: E8NqA5N4PaOvYUznDpeU6A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH 03/16] build-aux: introduce 'black' tool for python formatting Date: Wed, 8 Mar 2023 11:39:00 -0500 Message-Id: <20230308163913.338952-4-berrange@redhat.com> In-Reply-To: <20230308163913.338952-1-berrange@redhat.com> References: <20230308163913.338952-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678293606842100003 The 'black' tool is intended to be an opinionated formatting tool for python code. It is complementary to flake8 which validates coding bad practices, but (mostly) ignores code layout issues. Signed-off-by: Daniel P. Berrang=C3=A9 --- build-aux/Makefile.in | 1 + build-aux/meson.build | 5 +++++ build-aux/syntax-check.mk | 18 ++++++++++++++++++ meson.build | 1 + 4 files changed, 25 insertions(+) diff --git a/build-aux/Makefile.in b/build-aux/Makefile.in index 7ee4680847..db44ee36a4 100644 --- a/build-aux/Makefile.in +++ b/build-aux/Makefile.in @@ -3,6 +3,7 @@ top_srcdir =3D @top_srcdir@ top_builddir =3D @top_builddir@ FLAKE8 =3D @flake8_path@ +BLACK =3D @black_path@ RUNUTF8 =3D @runutf8@ PYTHON =3D @PYTHON3@ GREP =3D @GREP@ diff --git a/build-aux/meson.build b/build-aux/meson.build index 16d085505d..0330f2940c 100644 --- a/build-aux/meson.build +++ b/build-aux/meson.build @@ -2,6 +2,10 @@ flake8_path =3D '' if flake8_prog.found() flake8_path =3D flake8_prog.full_path() endif +black_path =3D '' +if black_prog.found() + black_path =3D black_prog.full_path() +endif =20 if host_machine.system() =3D=3D 'freebsd' or host_machine.system() =3D=3D = 'darwin' make_prog =3D find_program('gmake') @@ -32,6 +36,7 @@ syntax_check_conf =3D configuration_data({ 'top_srcdir': meson.project_source_root(), 'top_builddir': meson.project_build_root(), 'flake8_path': flake8_path, + 'black_path': black_path, 'runutf8': ' '.join(runutf8), 'PYTHON3': python3_prog.full_path(), 'GREP': grep_prog.full_path(), diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index 158f14e77e..6d82a4301a 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -595,6 +595,16 @@ sc_flake8: echo 'skipping test $@: flake8 not installed' 1>&2; \ fi =20 +sc_black: + if [ -n "$(BLACK)" ]; then \ + DOT_PY=3D$$($(VC_LIST_EXCEPT) | $(GREP) '\.py$$'); \ + BANG_PY=3D$$($(VC_LIST_EXCEPT) | xargs grep -l '^#!/usr/bin/env python3$= $'); \ + ALL_PY=3D$$(printf "%s\n%s" "$$DOT_PY" "$$BANG_PY" | sort -u); \ + echo "$$ALL_PY" | xargs $(BLACK) --check; \ + else \ + echo 'skipping test $@: black not installed' 1>&2; \ + fi + # mymain() in test files should use return, not exit, for nicer output sc_prohibit_exit_in_tests: @prohibit=3D'\&2; \ echo "*****************************************************" >&2; \ fi + if [ -z "$(BLACK)" ]; then \ + echo "*****************************************************" >&2; \ + echo "* black not installed, sc_black has been skipped *" >&2; \ + echo "*****************************************************" >&2; \ + fi endif =20 # Don't include duplicate header in the source (either *.c or *.h) @@ -1479,6 +1494,9 @@ exclude_file_name_regexp--sc_prohibit_select =3D \ ^build-aux/syntax-check\.mk|src/util/vireventglibwatch\.c|tests/meson\.b= uild$$ =20 =20 +exclude_file_name_regexp--sc_black =3D \ + ^tools/|src/|tests/|ci/|run\.in|scripts/[^/]*\.py + ## -------------- ## ## Implementation ## ## -------------- ## diff --git a/meson.build b/meson.build index 319ed790f9..f63fed8cb5 100644 --- a/meson.build +++ b/meson.build @@ -769,6 +769,7 @@ endforeach =20 optional_programs =3D [ 'augparse', + 'black', 'dmidecode', 'ebtables', 'flake8', --=20 2.39.1