source: vendor/python/2.5/PCbuild8/build_ssl.py@ 3225

Last change on this file since 3225 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 5.7 KB
Line 
1# Script for building the _ssl module for Windows.
2# Uses Perl to setup the OpenSSL environment correctly
3# and build OpenSSL, then invokes a simple nmake session
4# for _ssl.pyd itself.
5
6# THEORETICALLY, you can:
7# * Unpack the latest SSL release one level above your main Python source
8# directory. It is likely you will already find the zlib library and
9# any other external packages there.
10# * Install ActivePerl and ensure it is somewhere on your path.
11# * Run this script from the PCBuild directory.
12#
13# it should configure and build SSL, then build the ssl Python extension
14# without intervention.
15
16import os, sys, re
17
18# Find all "foo.exe" files on the PATH.
19def find_all_on_path(filename, extras = None):
20 entries = os.environ["PATH"].split(os.pathsep)
21 ret = []
22 for p in entries:
23 fname = os.path.abspath(os.path.join(p, filename))
24 if os.path.isfile(fname) and fname not in ret:
25 ret.append(fname)
26 if extras:
27 for p in extras:
28 fname = os.path.abspath(os.path.join(p, filename))
29 if os.path.isfile(fname) and fname not in ret:
30 ret.append(fname)
31 return ret
32
33# Find a suitable Perl installation for OpenSSL.
34# cygwin perl does *not* work. ActivePerl does.
35# Being a Perl dummy, the simplest way I can check is if the "Win32" package
36# is available.
37def find_working_perl(perls):
38 for perl in perls:
39 fh = os.popen(perl + ' -e "use Win32;"')
40 fh.read()
41 rc = fh.close()
42 if rc:
43 continue
44 return perl
45 print "Can not find a suitable PERL:"
46 if perls:
47 print " the following perl interpreters were found:"
48 for p in perls:
49 print " ", p
50 print " None of these versions appear suitable for building OpenSSL"
51 else:
52 print " NO perl interpreters were found on this machine at all!"
53 print " Please install ActivePerl and ensure it appears on your path"
54 print "The Python SSL module was not built"
55 return None
56
57# Locate the best SSL directory given a few roots to look into.
58def find_best_ssl_dir(sources):
59 candidates = []
60 for s in sources:
61 try:
62 s = os.path.abspath(s)
63 fnames = os.listdir(s)
64 except os.error:
65 fnames = []