Browse code

Merge pull request #968 from LocutusOfBorg/avoid-distutils

Avoid distutils usage at runtime

Florent Viard authored on 2018/05/03 19:31:08
Showing 1 changed files
... ...
@@ -57,7 +57,12 @@ import tempfile
57 57
 from copy import copy
58 58
 from optparse import OptionParser, Option, OptionValueError, IndentedHelpFormatter
59 59
 from logging import debug, info, warning, error
60
-from distutils.spawn import find_executable
60
+
61
+try:
62
+    from shutil import which
63
+except ImportError:
64
+    # python2 fallback code
65
+    from distutils.spawn import find_executable as which
61 66
 
62 67
 from ssl import SSLError
63 68
 import io
... ...
@@ -2274,7 +2279,7 @@ def run_configure(config_file, args):
2274 2274
         ]
2275 2275
     ## Option-specfic defaults
2276 2276
     if getattr(cfg, "gpg_command") == "":
2277
-        setattr(cfg, "gpg_command", find_executable("gpg"))
2277
+        setattr(cfg, "gpg_command", which("gpg"))
2278 2278
 
2279 2279
     if getattr(cfg, "proxy_host") == "" and os.getenv("http_proxy"):
2280 2280
         autodetected_encoding = locale.getpreferredencoding() or "UTF-8"