From 50704bced3775e9bc5b34f4295e282bfac7253f0 Mon Sep 17 00:00:00 2001 From: Mads Andreasen Date: Sun, 7 Apr 2024 16:12:50 +0200 Subject: Replace exe_exists function with shutil.which() The documentation for subprocess.run at https://docs.python.org/3/library/subprocess.html#popen-constructor has a warning, pointing to using shutil.which() instead of subprocess.run for detecting if exe files exists on the path. shutil.which() is used in many places already. --- mesonbuild/scripts/coverage.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mesonbuild/scripts') diff --git a/mesonbuild/scripts/coverage.py b/mesonbuild/scripts/coverage.py index 17a4a10ae..f01946944 100644 --- a/mesonbuild/scripts/coverage.py +++ b/mesonbuild/scripts/coverage.py @@ -5,7 +5,7 @@ from __future__ import annotations from mesonbuild import environment, mesonlib -import argparse, re, sys, os, subprocess, pathlib, stat +import argparse, re, sys, os, subprocess, pathlib, stat, shutil import typing as T def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build_root: str, log_dir: str, use_llvm_cov: bool, @@ -17,7 +17,7 @@ def coverage(outputs: T.List[str], source_root: str, subproject_root: str, build gcovr_exe = None else: gcovr_exe, gcovr_version = environment.detect_gcovr(gcovr_exe) - if llvm_cov_exe == '' or not mesonlib.exe_exists([llvm_cov_exe, '--version']): + if llvm_cov_exe == '' or shutil.which(llvm_cov_exe) is None: llvm_cov_exe = None lcov_exe, lcov_version, genhtml_exe = environment.detect_lcov_genhtml() -- cgit v1.2.3