Mercurial > hg
changeset 51849:4dc1fc2b2f3a
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.
author | Matt Harbison <mharbison@atto.com> |
---|---|
date | Thu, 05 Sep 2024 17:12:52 -0400 |
parents | 3f0db3b6bf14 |
children | f5c46c3518a5 |
files | setup.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 "