Skip to content

Commit 5d647a5

Browse files
emmanuel-ferdmansfc-gh-truwaseloadams
authored andcommitted
Modernize system executable detection across components (deepspeedai#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 <[email protected]> Co-authored-by: Olatunji Ruwase <[email protected]> Co-authored-by: Logan Adams <[email protected]> Signed-off-by: Max Kovalenko <[email protected]>
1 parent 762a2a1 commit 5d647a5

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

deepspeed/utils/numa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# ...
1010
# ]
1111

12-
import distutils
1312
import os
1413
import psutil
14+
import shutil
1515
import subprocess
1616

1717

@@ -50,7 +50,7 @@ def check_for_numactl_pkg():
5050
found = False
5151
for pkgmgr, data in libs.items():
5252
flag, lib, tool = data
53-
path = distutils.spawn.find_executable(pkgmgr)
53+
path = shutil.which(pkgmgr)
5454
if path is not None:
5555
cmd = [pkgmgr, flag, lib]
5656
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

op_builder/async_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# DeepSpeed Team
55

66
import os
7-
import distutils.spawn
7+
import shutil
88
import subprocess
99

1010
from .builder import TorchCPUOpBuilder
@@ -82,7 +82,7 @@ def check_for_libaio_pkg(self):
8282
found = False
8383
for pkgmgr, data in libs.items():
8484
flag, lib, tool = data
85-
path = distutils.spawn.find_executable(pkgmgr)
85+
path = shutil.which(pkgmgr)
8686
if path is not None:
8787
cmd = [pkgmgr, flag, lib]
8888
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

op_builder/cpu/async_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# DeepSpeed Team
55

6-
import distutils.spawn
6+
import shutil
77
import subprocess
88

99
from .builder import CPUOpBuilder
@@ -60,7 +60,7 @@ def check_for_libaio_pkg(self):
6060
found = False
6161
for pkgmgr, data in libs.items():
6262
flag, lib, tool = data
63-
path = distutils.spawn.find_executable(pkgmgr)
63+
path = shutil.which(pkgmgr)
6464
if path is not None:
6565
cmd = [pkgmgr, flag, lib]
6666
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

op_builder/npu/async_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# DeepSpeed Team
55

6-
import distutils.spawn
6+
import shutil
77
import subprocess
88

99
from .builder import NPUOpBuilder
@@ -72,7 +72,7 @@ def check_for_libaio_pkg(self):
7272
found = False
7373
for pkgmgr, data in libs.items():
7474
flag, lib, tool = data
75-
path = distutils.spawn.find_executable(pkgmgr)
75+
path = shutil.which(pkgmgr)
7676
if path is not None:
7777
cmd = [pkgmgr, flag, lib]
7878
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

op_builder/xpu/async_io.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# DeepSpeed Team
55

6-
import distutils.spawn
6+
import shutil
77
import subprocess
88

99
from .builder import OpBuilder
@@ -75,7 +75,7 @@ def check_for_libaio_pkg(self):
7575
found = False
7676
for pkgmgr, data in libs.items():
7777
flag, lib, tool = data
78-
path = distutils.spawn.find_executable(pkgmgr)
78+
path = shutil.which(pkgmgr)
7979
if path is not None:
8080
cmd = [pkgmgr, flag, lib]
8181
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

0 commit comments

Comments
 (0)