Skip to content

Commit

Permalink
Deprecated distutils module in Python 3.12
Browse files Browse the repository at this point in the history
For 3.0.x, alias shutil.which() as find_executable(); load distutils.find_executable() as itself on Python 2.
Reverts and replaces fcf0ba9, which had erroneous indentation.
  • Loading branch information
Lestropie committed Jul 30, 2024
1 parent 69ee9cc commit bfa00fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion bin/mrtrix3.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# For more details, see http://www.mrtrix.org/.

import os, sys
from distutils.spawn import find_executable

try:
# since importlib code below only works on Python 3.5+
Expand Down
7 changes: 6 additions & 1 deletion lib/mrtrix3/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@


import ctypes, errno, inspect, os, random, string, subprocess, time
from distutils.spawn import find_executable
# Function can be used in isolation if potentially needing to place quotation marks around a
# filesystem path that is to be included as part of a command string
try:
from shlex import quote
except ImportError:
from pipes import quote
# Distutils removed in 3.12, but shutil.which not available in 2.7
try:
from shutil import which as find_executable
except ImportError:
from distutils.spawn import find_executable

from mrtrix3 import CONFIG
from mrtrix3.utils import STRING_TYPES

Expand Down
7 changes: 6 additions & 1 deletion lib/mrtrix3/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
# pylint: disable=unspecified-encoding

import collections, itertools, os, shlex, signal, string, subprocess, sys, tempfile, threading
from distutils.spawn import find_executable
from mrtrix3 import ANSI, BIN_PATH, COMMAND_HISTORY_STRING, EXE_LIST, MRtrixBaseError, MRtrixError
from mrtrix3.utils import STRING_TYPES

# Distutils removed in 3.12, but shutil.which not available in 2.7
try:
from shutil import which as find_executable
except ImportError:
from distutils.spawn import find_executable

IOStream = collections.namedtuple('IOStream', 'handle filename')


Expand Down

0 comments on commit bfa00fc

Please sign in to comment.