Modernize system executable detection across components (#7290)

# PR Summary
This small PR resolves deprecation warnings caused by the use of
`distutils.spawn.find_executable`:
```python
DeprecationWarning: Use shutil.which instead of find_executable
```
Please note that `find_executable` is deprecated from Python 3.10 and
removed in 3.12. `shutil.which` available since Python 3.3.

Signed-off-by: Emmanuel Ferdman <emmanuelferdman@gmail.com>
Co-authored-by: Olatunji Ruwase <tunji.ruwase@snowflake.com>
Co-authored-by: Logan Adams <114770087+loadams@users.noreply.github.com>
This commit is contained in:
Emmanuel Ferdman
2025-05-20 00:42:42 +03:00
committed by GitHub
parent d0ef6501b8
commit b048cc2b46
5 changed files with 10 additions and 10 deletions

View File

@ -9,9 +9,9 @@
# ...
# ]
import distutils
import os
import psutil
import shutil
import subprocess
@ -50,7 +50,7 @@ def check_for_numactl_pkg():
found = False
for pkgmgr, data in libs.items():
flag, lib, tool = data
path = distutils.spawn.find_executable(pkgmgr)
path = shutil.which(pkgmgr)
if path is not None:
cmd = [pkgmgr, flag, lib]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@ -4,7 +4,7 @@
# DeepSpeed Team
import os
import distutils.spawn
import shutil
import subprocess
from .builder import TorchCPUOpBuilder
@ -82,7 +82,7 @@ class AsyncIOBuilder(TorchCPUOpBuilder):
found = False
for pkgmgr, data in libs.items():
flag, lib, tool = data
path = distutils.spawn.find_executable(pkgmgr)
path = shutil.which(pkgmgr)
if path is not None:
cmd = [pkgmgr, flag, lib]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@ -3,7 +3,7 @@
# DeepSpeed Team
import distutils.spawn
import shutil
import subprocess
from .builder import CPUOpBuilder
@ -60,7 +60,7 @@ class AsyncIOBuilder(CPUOpBuilder):
found = False
for pkgmgr, data in libs.items():
flag, lib, tool = data
path = distutils.spawn.find_executable(pkgmgr)
path = shutil.which(pkgmgr)
if path is not None:
cmd = [pkgmgr, flag, lib]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@ -3,7 +3,7 @@
# DeepSpeed Team
import distutils.spawn
import shutil
import subprocess
from .builder import NPUOpBuilder
@ -72,7 +72,7 @@ class AsyncIOBuilder(NPUOpBuilder):
found = False
for pkgmgr, data in libs.items():
flag, lib, tool = data
path = distutils.spawn.find_executable(pkgmgr)
path = shutil.which(pkgmgr)
if path is not None:
cmd = [pkgmgr, flag, lib]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

View File

@ -3,7 +3,7 @@
# DeepSpeed Team
import distutils.spawn
import shutil
import subprocess
from .builder import OpBuilder
@ -75,7 +75,7 @@ class AsyncIOBuilder(OpBuilder):
found = False
for pkgmgr, data in libs.items():
flag, lib, tool = data
path = distutils.spawn.find_executable(pkgmgr)
path = shutil.which(pkgmgr)
if path is not None:
cmd = [pkgmgr, flag, lib]
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)