Skip to content

Commit e436eba

Browse files
committed
Merge branch 'fix_python3.12_deprecation' into 'master'
Fix deprecation issue for python 3.12 for distutil.spawn See merge request evernym/utilities/devlab!22
2 parents 2493a6a + 96ce76c commit e436eba

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

installer.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"""
66

77
import argparse
8-
import distutils.spawn
98
import json
109
import logging
1110
import os
@@ -18,6 +17,11 @@
1817
import tarfile
1918
from io import BytesIO
2019

20+
try:
21+
from shutil import which
22+
except ImportError:
23+
from distutils.spawn import find_executable as which
24+
2125
try:
2226
#For python3
2327
from urllib import request as url_request
@@ -146,7 +150,7 @@ def action_install(repo_path, set_version=None, **kwargs):
146150
exc_val=exc_value
147151
)
148152
log.error(exc_str)
149-
if not distutils.spawn.find_executable('python'):
153+
if not which('python'):
150154
log.warning("The executable 'python' is not found in your PATH. Checking for others...")
151155
for path in os.environ.get('PATH', '/usr/bin:/bin:/usr/local/bin').split(':'):
152156
found_files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f)) and re.match(r'python[0-9\.]*$', f)]
@@ -294,7 +298,7 @@ def find_cur_version():
294298
os.chdir(
295299
os.path.expanduser('~')
296300
)
297-
cur_path = distutils.spawn.find_executable('devlab')
301+
cur_path = which('devlab')
298302
log.debug("Path where 'devlab' executable resides: %s", cur_path)
299303
if cur_path == 'devlab':
300304
cur_path = None

0 commit comments

Comments
 (0)