Skip to content

Commit

Permalink
Merge branch 'fix_python3.12_deprecation' into 'master'
Browse files Browse the repository at this point in the history
Fix deprecation issue for python 3.12 for distutil.spawn

See merge request evernym/utilities/devlab!22
  • Loading branch information
absltkaos committed Jun 9, 2023
2 parents 2493a6a + 96ce76c commit e436eba
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""

import argparse
import distutils.spawn
import json
import logging
import os
Expand All @@ -18,6 +17,11 @@
import tarfile
from io import BytesIO

try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which

try:
#For python3
from urllib import request as url_request
Expand Down Expand Up @@ -146,7 +150,7 @@ def action_install(repo_path, set_version=None, **kwargs):
exc_val=exc_value
)
log.error(exc_str)
if not distutils.spawn.find_executable('python'):
if not which('python'):
log.warning("The executable 'python' is not found in your PATH. Checking for others...")
for path in os.environ.get('PATH', '/usr/bin:/bin:/usr/local/bin').split(':'):
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)]
Expand Down Expand Up @@ -294,7 +298,7 @@ def find_cur_version():
os.chdir(
os.path.expanduser('~')
)
cur_path = distutils.spawn.find_executable('devlab')
cur_path = which('devlab')
log.debug("Path where 'devlab' executable resides: %s", cur_path)
if cur_path == 'devlab':
cur_path = None
Expand Down

0 comments on commit e436eba

Please sign in to comment.