third_party: Update waf to version 2.0.17
[samba.git] / third_party / waf / waflib / Utils.py
index b4665c4dc2bbf64fd723206b944a42ab8a5f03da..7472226da58183df7d37aadb8f6ad6d77ab2deac 100644 (file)
@@ -49,10 +49,16 @@ try:
        from hashlib import md5
 except ImportError:
        try:
-               from md5 import md5
+               from hashlib import sha1 as md5
        except ImportError:
-               # never fail to enable fixes from another module
+               # never fail to enable potential fixes from another module
                pass
+else:
+       try:
+               md5().digest()
+       except ValueError:
+               # Fips? #2213
+               from hashlib import sha1 as md5
 
 try:
        import threading
@@ -202,7 +208,7 @@ class lazy_generator(object):
 
        next = __next__
 
-is_win32 = os.sep == '\\' or sys.platform == 'win32' # msys2
+is_win32 = os.sep == '\\' or sys.platform == 'win32' or os.name == 'nt' # msys2
 """
 Whether this system is a Windows series
 """
@@ -484,7 +490,9 @@ def split_path_msys(path):
 if sys.platform == 'cygwin':
        split_path = split_path_cygwin
 elif is_win32:
-       if os.environ.get('MSYSTEM'):
+       # Consider this an MSYSTEM environment if $MSYSTEM is set and python
+       # reports is executable from a unix like path on a windows host.
+       if os.environ.get('MSYSTEM') and sys.executable.startswith('/'):
                split_path = split_path_msys
        else:
                split_path = split_path_win32
@@ -596,6 +604,12 @@ def h_list(lst):
        """
        return md5(repr(lst).encode()).digest()
 
+if sys.hexversion < 0x3000000:
+       def h_list_python2(lst):
+               return md5(repr(lst)).digest()
+       h_list_python2.__doc__ = h_list.__doc__
+       h_list = h_list_python2
+
 def h_fun(fun):
        """
        Hash functions
@@ -730,7 +744,7 @@ def unversioned_sys_platform():
        if s == 'cli' and os.name == 'nt':
                # ironpython is only on windows as far as we know
                return 'win32'
-       return re.split('\d+$', s)[0]
+       return re.split(r'\d+$', s)[0]
 
 def nada(*k, **kw):
        """
@@ -871,7 +885,7 @@ def get_process():
        except IndexError:
                filepath = os.path.dirname(os.path.abspath(__file__)) + os.sep + 'processor.py'
                cmd = [sys.executable, '-c', readf(filepath)]
-               return subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, bufsize=0)
+               return subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, bufsize=0, close_fds=not is_win32)
 
 def run_prefork_process(cmd, kwargs, cargs):
        """