[Python-checkins] r85072 - python/branches/py3k/PC/VC6/build_ssl.py

hirokazu.yamamoto python-checkins at python.org
Tue Sep 28 20:36:05 CEST 2010


Author: hirokazu.yamamoto
Date: Tue Sep 28 20:36:04 2010
New Revision: 85072

Log:
Updated PC/VC6 openssl build script. (for openssl-1.0.0a)

Modified:
   python/branches/py3k/PC/VC6/build_ssl.py

Modified: python/branches/py3k/PC/VC6/build_ssl.py
==============================================================================
--- python/branches/py3k/PC/VC6/build_ssl.py	(original)
+++ python/branches/py3k/PC/VC6/build_ssl.py	Tue Sep 28 20:36:04 2010
@@ -13,6 +13,11 @@
 # it should configure and build SSL, then build the ssl Python extension
 # without intervention.
 
+# Modified by Christian Heimes
+# Now this script supports pre-generated makefiles and assembly files.
+# Developers don't need an installation of Perl anymore to build Python. A svn
+# checkout from our svn repository is enough.
+
 import os, sys, re, shutil
 
 # Find all "foo.exe" files on the PATH.
@@ -36,7 +41,7 @@
 # is available.
 def find_working_perl(perls):
     for perl in perls:
-        fh = os.popen(perl + ' -e "use Win32;"')
+        fh = os.popen('"%s" -e "use Win32;"' % perl)
         fh.read()
         rc = fh.close()
         if rc:
@@ -90,13 +95,9 @@
     """
     if not os.path.isfile(makefile):
         return
-    # 2.4 compatibility
-    fin = open(makefile)
-    if 1: # with open(makefile) as fin:
+    with open(makefile) as fin:
         lines = fin.readlines()
-        fin.close()
-    fout = open(makefile, 'w')
-    if 1: # with open(makefile, 'w') as fout:
+    with open(makefile, 'w') as fout:
         for line in lines:
             if line.startswith("PERL="):
                 continue
@@ -112,7 +113,6 @@
                         line = line + noalgo
                 line = line + '\n'
             fout.write(line)
-    fout.close()
 
 def run_configure(configure, do_script):
     print("perl Configure "+configure)
@@ -120,6 +120,22 @@
     print(do_script)
     os.system(do_script)
 
+def cmp(f1, f2):
+    bufsize = 1024 * 8
+    with open(f1, 'rb') as fp1, open(f2, 'rb') as fp2:
+        while True:
+            b1 = fp1.read(bufsize)
+            b2 = fp2.read(bufsize)
+            if b1 != b2:
+                return False
+            if not b1:
+                return True
+
+def copy(src, dst):
+    if os.path.isfile(dst) and cmp(src, dst):
+        return
+    shutil.copy(src, dst)
+
 def main():
     debug = "-d" in sys.argv
     build_all = "-a" in sys.argv
@@ -129,6 +145,7 @@
         do_script = "ms\\do_nasm"
         makefile="ms\\nt.mak"
         m32 = makefile
+        dirsuffix = "32"
     configure += " no-idea no-rc5 no-mdc2"
     make_flags = ""
     if build_all:
@@ -137,12 +154,12 @@
     # as "well known" locations
     perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
     perl = find_working_perl(perls)
-    if perl is None:
-        print("No Perl installation was found. Existing Makefiles are used.")
-    else:
+    if perl:
         print("Found a working perl at '%s'" % (perl,))
+    else:
+        print("No Perl installation was found. Existing Makefiles are used.")
     sys.stdout.flush()
-    # Look for SSL 3 levels up from pcbuild - ie, same place zlib etc all live.
+    # Look for SSL 3 levels up from PC/VC6 - ie, same place zlib etc all live.
     ssl_dir = find_best_ssl_dir(("..\\..\\..",))
     if ssl_dir is None:
         sys.exit(1)
@@ -173,12 +190,21 @@
             #    os.system("perl util\mk1mf.pl debug "+configure+" >"+makefile)
 
             fix_makefile(makefile)
-            shutil.copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
-            shutil.copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
+            copy(r"crypto\buildinf.h", r"crypto\buildinf_%s.h" % arch)
+            copy(r"crypto\opensslconf.h", r"crypto\opensslconf_%s.h" % arch)
+
+        # If the assembler files don't exist in tmpXX, copy them there
+        if perl is None:
+            if not os.path.exists("tmp"+dirsuffix):
+                os.mkdir("tmp"+dirsuffix)
+            for f in os.listdir("asm"+dirsuffix):
+                if not f.endswith(".asm"): continue
+                if os.path.isfile(r"tmp%s\%s" % (dirsuffix, f)): continue
+                shutil.copy(r"asm%s\%s" % (dirsuffix, f), "tmp"+dirsuffix)
 
         # Now run make.
-        shutil.copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")
-        shutil.copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")
+        copy(r"crypto\buildinf_%s.h" % arch, r"crypto\buildinf.h")
+        copy(r"crypto\opensslconf_%s.h" % arch, r"crypto\opensslconf.h")
 
         #makeCommand = "nmake /nologo PERL=\"%s\" -f \"%s\"" %(perl, makefile)
         makeCommand = "nmake /nologo -f \"%s\"" % makefile


More information about the Python-checkins mailing list