Skip to content

Commit a677e8a

Browse files
authored
Replace distutils.spawn.find_executable by shutil.which (#253)
2 parents 4e9d5cc + 7ea4ae2 commit a677e8a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sapphire/tests/test_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,5 @@ def test_which(self):
189189
def test_non_existent_program(self):
190190
"""Check for error for non-existent program"""
191191

192-
self.assertRaises(Exception, utils.which, 'a_very_unlikely_program_name_to_exist_cosmic_ray')
192+
with self.assertRaises(RuntimeError):
193+
utils.which('a_very_unlikely_program_name_to_exist_cosmic_ray')

sapphire/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
The module contains some commonly functions and classes.
44
55
"""
6+
import shutil
67

78
from bisect import bisect_right
89
from contextlib import suppress
9-
from distutils.spawn import find_executable
1010
from functools import wraps
1111
from os import environ
1212

@@ -169,7 +169,7 @@ def which(program):
169169
:param program: name or program to check for, e.g. 'wget'.
170170
171171
"""
172-
path = find_executable(program)
172+
path = shutil.which(program)
173173
if not path:
174174
raise RuntimeError(f'The program {program} is not available.')
175175

0 commit comments

Comments
 (0)