Skip to content

Commit de27864

Browse files
committed
Make distutils optional
* move the import of distutils to where it is required * also catches ModuleNotFoundErrors occuring from 3.12 onwards Signed-off-by: Adrian Braemer <[email protected]>
1 parent bc8b96d commit de27864

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

whipper/command/main.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import musicbrainzngs
88
import site
99
import whipper
10-
from distutils.sysconfig import get_python_lib
1110
from whipper.command import cd, offset, drive, image, accurip, mblookup
1211
from whipper.command.basecommand import BaseCommand
1312
from whipper.common import common, directory, config
@@ -38,11 +37,16 @@ def main():
3837
# Find whipper's plugins paths (local paths have higher priority)
3938
plugins_p = [directory.data_path('plugins')] # local path (in $HOME)
4039
if hasattr(sys, 'real_prefix'): # no getsitepackages() in virtualenv
41-
plugins_p.append(
42-
get_python_lib(plat_specific=False, standard_lib=False,
43-
prefix='/usr/local') + '/whipper/plugins')
44-
plugins_p.append(get_python_lib(plat_specific=False,
45-
standard_lib=False) + '/whipper/plugins')
40+
try:
41+
from distutils.sysconfig import get_python_lib
42+
plugins_p.append(
43+
get_python_lib(plat_specific=False, standard_lib=False,
44+
prefix='/usr/local') + '/whipper/plugins')
45+
plugins_p.append(get_python_lib(plat_specific=False,
46+
standard_lib=False) + '/whipper/plugins')
47+
except ModuleNotFoundError:
48+
logger.error("Failed to import distutils. Some plugins might "
49+
"be unavailable.")
4650
else:
4751
plugins_p += [x + '/whipper/plugins' for x in site.getsitepackages()]
4852

0 commit comments

Comments
 (0)