public inbox for buildbot@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: buildbot@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 1/8] autoregen.py: re-format with black 24.2.0
Date: Mon, 11 Mar 2024 15:01:13 -0400	[thread overview]
Message-ID: <20240311190341.235331-2-simon.marchi@efficios.com> (raw)
In-Reply-To: <20240311190341.235331-1-simon.marchi@efficios.com>

This is subjective, but I am completely sold on using black for Python
projects, so I propose using it here.  It lets us completely stop
thinking about formatting whatsoever.
---
 builder/containers/autoregen.py | 72 ++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 32 deletions(-)

diff --git a/builder/containers/autoregen.py b/builder/containers/autoregen.py
index 3d307ad24132..861a2ce79ef5 100755
--- a/builder/containers/autoregen.py
+++ b/builder/containers/autoregen.py
@@ -5,12 +5,13 @@ import shutil
 import subprocess
 from pathlib import Path
 
+
 # On Gentoo, vanilla unpatched autotools are packaged separately.
 # We place the vanilla names first as we want to prefer those if both exist.
-autoconf_names = ['autoconf-vanilla-2.69', 'autoconf-2.69']
-automake_names = ['automake-vanilla-1.15', 'automake-1.15.1']
-aclocal_names = ['aclocal-vanilla-1.15', 'aclocal-1.15.1']
-autoheader_names = ['autoheader-vanilla-2.69', 'autoheader-2.69']
+autoconf_names = ["autoconf-vanilla-2.69", "autoconf-2.69"]
+automake_names = ["automake-vanilla-1.15", "automake-1.15.1"]
+aclocal_names = ["aclocal-vanilla-1.15", "aclocal-1.15.1"]
+autoheader_names = ["autoheader-vanilla-2.69", "autoheader-2.69"]
 
 # Pick the first for each list that exists on this system.
 AUTOCONF_BIN = next(name for name in autoconf_names if shutil.which(name))
@@ -23,23 +24,24 @@ AUTOHEADER_BIN = next(name for name in autoheader_names if shutil.which(name))
 ENV = f'WANT_AUTOCONF={AUTOCONF_BIN.split("-", 1)[1]} '
 ENV += f'WANT_AUTOMAKE={AUTOMAKE_BIN.split("-", 1)[1]} '
 
-ENV += f' AUTOCONF={AUTOCONF_BIN} '
-ENV += f' ACLOCAL={ACLOCAL_BIN} '
-ENV += f' AUTOMAKE={AUTOMAKE_BIN}'
+ENV += f" AUTOCONF={AUTOCONF_BIN} "
+ENV += f" ACLOCAL={ACLOCAL_BIN} "
+ENV += f" AUTOMAKE={AUTOMAKE_BIN}"
+
 
 # Directories we should skip entirely because they're vendored or have different
 # autotools versions.
 skip_dirs = [
     # readline and minizip are maintained with different autotools versions
-    'readline',
-    'minizip'
+    "readline",
+    "minizip",
 ]
 
 config_folders = []
 
-for root, _, files in os.walk('.'):
+for root, _, files in os.walk("."):
     for file in files:
-        if file == 'configure.ac':
+        if file == "configure.ac":
             config_folders.append(Path(root).resolve())
 
 for folder in sorted(config_folders):
@@ -50,31 +52,37 @@ for folder in sorted(config_folders):
 
     os.chdir(folder)
 
-    configure_lines = open('configure.ac').read().splitlines()
-    if any(True for line in configure_lines if line.startswith('AC_CONFIG_MACRO_DIRS')):
+    configure_lines = open("configure.ac").read().splitlines()
+    if any(True for line in configure_lines if line.startswith("AC_CONFIG_MACRO_DIRS")):
         # aclocal does not support the -f short option for force
-        include_arg = ''
-        include_arg2 = ''
-        if (folder / '..' / 'config').is_dir():
-            include_arg = '-I../config'
+        include_arg = ""
+        include_arg2 = ""
+        if (folder / ".." / "config").is_dir():
+            include_arg = "-I../config"
 
         # this is really a hack just for binutils-gdb/gprofng/libcollector
         # make sure that the order of includes is done as --enable-maintainer-mode
-        if (folder / '..' / '..' / 'config').is_dir():
-            include_arg = '-I../..'
-            include_arg2 = '-I../../config'
-
-        subprocess.check_output(f'{ENV} {ACLOCAL_BIN} --force {include_arg} {include_arg2}', shell=True, encoding='utf8')
-
-    if ((folder / 'config.in').is_file()
-        or any(True for line in configure_lines if line.startswith('AC_CONFIG_HEADERS'))):
-        subprocess.check_output(f'{ENV} {AUTOHEADER_BIN} -f', shell=True, encoding='utf8')
+        if (folder / ".." / ".." / "config").is_dir():
+            include_arg = "-I../.."
+            include_arg2 = "-I../../config"
+
+        subprocess.check_output(
+            f"{ENV} {ACLOCAL_BIN} --force {include_arg} {include_arg2}",
+            shell=True,
+            encoding="utf8",
+        )
+
+    if (folder / "config.in").is_file() or any(
+        True for line in configure_lines if line.startswith("AC_CONFIG_HEADERS")
+    ):
+        subprocess.check_output(
+            f"{ENV} {AUTOHEADER_BIN} -f", shell=True, encoding="utf8"
+        )
 
     # apparently automake is somehow unstable -> skip it for gotools
-    if (any(True for line in configure_lines if line.startswith('AM_INIT_AUTOMAKE'))
-            and not str(folder).endswith('gotools')):
-        subprocess.check_output(f'{ENV} {AUTOMAKE_BIN} -f',
-                                shell=True, encoding='utf8')
-
-    subprocess.check_output(f'{ENV} {AUTOCONF_BIN} -f', shell=True, encoding='utf8')
+    if any(
+        True for line in configure_lines if line.startswith("AM_INIT_AUTOMAKE")
+    ) and not str(folder).endswith("gotools"):
+        subprocess.check_output(f"{ENV} {AUTOMAKE_BIN} -f", shell=True, encoding="utf8")
 
+    subprocess.check_output(f"{ENV} {AUTOCONF_BIN} -f", shell=True, encoding="utf8")
-- 
2.44.0


  reply	other threads:[~2024-03-11 19:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 19:01 [PATCH 0/8] Some changes to autoregen.py Simon Marchi
2024-03-11 19:01 ` Simon Marchi [this message]
2024-03-11 19:01 ` [PATCH 2/8] autoregen.py: fix a pyright `reportConstantRedefinition` warning Simon Marchi
     [not found]   ` <871q8f7jx5.fsf@aarsen.me>
2024-03-12 16:00     ` Simon Marchi
2024-03-13  8:58       ` Mark Wielaard
2024-03-18 17:36         ` Arsen Arsenović
2024-03-11 19:01 ` [PATCH 3/8] autoregen.py: add type annotation for config_folders Simon Marchi
2024-03-11 19:01 ` [PATCH 4/8] autoregen.py: capitalize some constant names Simon Marchi
2024-03-11 19:01 ` [PATCH 5/8] autoregen.py: add non-suffixed version of the tools Simon Marchi
2024-03-11 19:01 ` [PATCH 6/8] autoregen.py: print executed commands on stdout Simon Marchi
2024-03-11 19:01 ` [PATCH 7/8] autoregen.py: let subprocesses print to stdout/stderr Simon Marchi
     [not found]   ` <87plvz7k10.fsf@aarsen.me>
2024-03-12 15:40     ` Simon Marchi
2024-03-13  8:46       ` Mark Wielaard
2024-03-11 19:01 ` [PATCH 8/8] autoregen.py: be more verbose Simon Marchi
2024-03-11 21:04 ` [PATCH 0/8] Some changes to autoregen.py Sam James
2024-03-11 21:52   ` Mark Wielaard
2024-03-12  1:53     ` Simon Marchi
2024-03-12 10:17       ` Mark Wielaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240311190341.235331-2-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=buildbot@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).