]> granicus.if.org Git - python/commitdiff
Issue10752 Be more robust when finding a PERL interpreter to build OpenSSL. Initial...
authorTim Golden <mail@timgolden.me.uk>
Fri, 9 May 2014 17:01:19 +0000 (18:01 +0100)
committerTim Golden <mail@timgolden.me.uk>
Fri, 9 May 2014 17:01:19 +0000 (18:01 +0100)
PCbuild/build_ssl.py

index 5a7a89e4ec9bb6d9a3719df90ecfc8e1b356f26e..dc517813e189ad99fd05cdecc734c034d16e46f5 100644 (file)
@@ -24,6 +24,7 @@
 # python.exe build_ssl.py Release Win32
 
 import os, sys, re, shutil
+import subprocess
 
 # Find all "foo.exe" files on the PATH.
 def find_all_on_path(filename, extras = None):
@@ -46,22 +47,21 @@ def find_all_on_path(filename, extras = None):
 # is available.
 def find_working_perl(perls):
     for perl in perls:
-        fh = os.popen('"%s" -e "use Win32;"' % perl)
-        fh.read()
-        rc = fh.close()
-        if rc:
+        try:
+            subprocess.check_output([perl, "-e", "use Win32;"])
+        except subprocess.CalledProcessError:
             continue
-        return perl
-    print("Can not find a suitable PERL:")
+        else:
+            return perl
+
     if perls:
-        print(" the following perl interpreters were found:")
+        print("The following perl interpreters were found:")
         for p in perls:
             print(" ", p)
         print(" None of these versions appear suitable for building OpenSSL")
     else:
-        print(" NO perl interpreters were found on this machine at all!")
+        print("NO perl interpreters were found on this machine at all!")
     print(" Please install ActivePerl and ensure it appears on your path")
-    return None
 
 # Fetch SSL directory from VC properties
 def get_ssl_dir():