setup: avoid the deprecated `distutils.spawn.find_executable`
I noticed this was flagged with `DeprecationWarning` in py3.12 with `setuptools`
74.1.2, and it suggested `shutil.which()` instead. The signatures aren't the
same, but the additional `mode` argument in the middle of the latter defaults to
`os.F_OK | os.X_OK`, which maintains the same semantics.
--- a/setup.py Thu Sep 05 16:59:36 2024 -0400
+++ b/setup.py Thu Sep 05 17:12:52 2024 -0400
@@ -125,7 +125,7 @@
from distutils.command.install_lib import install_lib
from distutils.command.install_scripts import install_scripts
from distutils import log
-from distutils.spawn import spawn, find_executable
+from distutils.spawn import spawn
from distutils import file_util
from distutils.errors import (
CCompilerError,
@@ -464,6 +464,12 @@
description = "build translations (.mo files)"
def run(self):
+ try:
+ from shutil import which as find_executable
+ except ImportError:
+ # Deprecated in py3.12
+ from distutils.spawn import find_executable
+
if not find_executable('msgfmt'):
self.warn(
"could not find msgfmt executable, no translations "