]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: remove distutils dependency 33374/head
authorSage Weil <sage@redhat.com>
Tue, 18 Feb 2020 14:44:36 +0000 (08:44 -0600)
committerSage Weil <sage@redhat.com>
Wed, 19 Feb 2020 13:15:20 +0000 (07:15 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/cephadm/cephadm

index a312c1b3dd9f63f11282495792de96ca24631b0d..36a35a7f40a8d6c8f4ac4f894e767f71138e897f 100755 (executable)
@@ -57,7 +57,6 @@ except ImportError:
     pass
 import uuid
 
-from distutils.spawn import find_executable
 from functools import wraps
 from glob import glob
 from threading import Thread
@@ -809,6 +808,42 @@ def move_files(src, dst, uid=None, gid=None):
             logger.debug('chown %s:%s \'%s\'' % (uid, gid, dst_file))
             os.chown(dst_file, uid, gid)
 
+## copied from distutils ##
+def find_executable(executable, path=None):
+    """Tries to find 'executable' in the directories listed in 'path'.
+    A string listing directories separated by 'os.pathsep'; defaults to
+    os.environ['PATH'].  Returns the complete filename or None if not found.
+    """
+    _, ext = os.path.splitext(executable)
+    if (sys.platform == 'win32') and (ext != '.exe'):
+        executable = executable + '.exe'
+
+    if os.path.isfile(executable):
+        return executable
+
+    if path is None:
+        path = os.environ.get('PATH', None)
+        if path is None:
+            try:
+                path = os.confstr("CS_PATH")
+            except (AttributeError, ValueError):
+                # os.confstr() or CS_PATH is not available
+                path = os.defpath
+        # bpo-35755: Don't use os.defpath if the PATH environment variable is
+        # set to an empty string
+
+    # PATH='' doesn't match, whereas PATH=':' looks in the current directory
+    if not path:
+        return None
+
+    paths = path.split(os.pathsep)
+    for p in paths:
+        f = os.path.join(p, executable)
+        if os.path.isfile(f):
+            # the file exists, we have a shot at spawn working
+            return f
+    return None
+
 def find_program(filename):
     # type: (str) -> str
     name = find_executable(filename)