Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/PCbuild/build_ssl.py

    r2 r391  
     1from __future__ import with_statement, print_function
    12# Script for building the _ssl and _hashlib modules for Windows.
    23# Uses Perl to setup the OpenSSL environment correctly
     
    4748def find_working_perl(perls):
    4849    for perl in perls:
    49         fh = os.popen(perl + ' -e "use Win32;"')
     50        fh = os.popen('"%s" -e "use Win32;"' % perl)
    5051        fh.read()
    5152        rc = fh.close()
     
    6465    return None
    6566
    66 # Locate the best SSL directory given a few roots to look into.
    67 def find_best_ssl_dir(sources):
    68     candidates = []
    69     for s in sources:
    70         try:
    71             # note: do not abspath s; the build will fail if any
    72             # higher up directory name has spaces in it.
    73             fnames = os.listdir(s)
    74         except os.error:
    75             fnames = []
    76         for fname in fnames:
    77             fqn = os.path.join(s, fname)
    78             if os.path.isdir(fqn) and fname.startswith("openssl-"):
    79                 candidates.append(fqn)
    80     # Now we have all the candidates, locate the best.
    81     best_parts = []
    82     best_name = None
    83     for c in candidates:
    84         parts = re.split("[.-]", os.path.basename(c))[1:]
    85         # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers
    86         if len(parts) >= 4:
    87             continue
    88         if parts > best_parts:
    89             best_parts = parts
    90             best_name = c
    91     if best_name is not None:
    92         print("Found an SSL directory at '%s'" % (best_name,))
    93     else:
    94         print("Could not find an SSL directory in '%s'" % (sources,))
    95     sys.stdout.flush()
    96     return best_name
     67# Fetch SSL directory from VC properties
     68def get_ssl_dir():
     69    propfile = (os.path.join(os.path.dirname(__file__), 'pyproject.vsprops'))
     70    with open(propfile) as f:
     71        m = re.search('openssl-([^"]+)"', f.read())
     72        return "..\..\openssl-"+m.group(1)
     73
    9774
    9875def create_makefile64(makefile, m32):
     
    10380    if not os.path.isfile(m32):
    10481        return
    105     # 2.4 compatibility
    106     fin = open(m32)
    107     if 1: # with open(m32) as fin:
    108         fout = open(makefile, 'w')
    109         if 1: # with open(makefile, 'w') as fout:
     82    with open(m32) as fin:
     83        with open(makefile, 'w') as fout:
    11084            for line in fin:
    11185                line = line.replace("=tmp32", "=tmp64")
     
    187161    perls = find_all_on_path("perl.exe", ["\\perl\\bin", "C:\\perl\\bin"])
    188162    perl = find_working_perl(perls)
    189     if perl is None:
     163    if perl:
     164        print("Found a working perl at '%s'" % (perl,))
     165    else:
    190166        print("No Perl installation was found. Existing Makefiles are used.")
    191 
    192     print("Found a working perl at '%s'" % (perl,))
    193167    sys.stdout.flush()
    194168    # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live.
    195     ssl_dir = find_best_ssl_dir(("..\\..",))
     169    ssl_dir = get_ssl_dir()
    196170    if ssl_dir is None:
    197171        sys.exit(1)
Note: See TracChangeset for help on using the changeset viewer.