diff options
Diffstat (limited to 'PCbuild')
-rw-r--r-- | PCbuild/_ssl.dsp | 89 | ||||
-rw-r--r-- | PCbuild/_ssl.mak | 20 | ||||
-rw-r--r-- | PCbuild/build_ssl.py | 143 | ||||
-rw-r--r-- | PCbuild/pcbuild.dsw | 21 | ||||
-rw-r--r-- | PCbuild/readme.txt | 30 |
5 files changed, 303 insertions, 0 deletions
diff --git a/PCbuild/_ssl.dsp b/PCbuild/_ssl.dsp new file mode 100644 index 0000000..d87aecc --- /dev/null +++ b/PCbuild/_ssl.dsp @@ -0,0 +1,89 @@ +# Microsoft Developer Studio Project File - Name="_ssl" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) External Target" 0x0106 + +CFG=_ssl - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "_ssl.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "_ssl.mak" CFG="_ssl - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "_ssl - Win32 Release" (based on "Win32 (x86) External Target") +!MESSAGE "_ssl - Win32 Debug" (based on "Win32 (x86) External Target") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" + +!IF "$(CFG)" == "_ssl - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "_ssl.exe" +# PROP BASE Bsc_Name "_ssl.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "." +# PROP Intermediate_Dir "x86-temp-release\_ssl" +# PROP Cmd_Line "python build_ssl.py" +# PROP Rebuild_Opt "-a" +# PROP Target_File "_ssl.pyd" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "x86-temp-debug\_ssl" +# PROP BASE Intermediate_Dir "x86-temp-debug\_ssl" +# PROP BASE Cmd_Line "NMAKE /f _ssl.mak" +# PROP BASE Rebuild_Opt "/a" +# PROP BASE Target_File "_ssl_d.pyd" +# PROP BASE Bsc_Name "_ssl_d.bsc" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "." +# PROP Intermediate_Dir "x86-temp-debug\_ssl" +# PROP Cmd_Line "python -u build_ssl.py -d" +# PROP Rebuild_Opt "-a" +# PROP Target_File "_ssl_d.pyd" +# PROP Bsc_Name "" +# PROP Target_Dir "" + +!ENDIF + +# Begin Target + +# Name "_ssl - Win32 Release" +# Name "_ssl - Win32 Debug" + +!IF "$(CFG)" == "_ssl - Win32 Release" + +!ELSEIF "$(CFG)" == "_ssl - Win32 Debug" + +!ENDIF + +# Begin Source File + +SOURCE=..\Modules\_ssl.c +# End Source File +# End Target +# End Project diff --git a/PCbuild/_ssl.mak b/PCbuild/_ssl.mak new file mode 100644 index 0000000..8e441b0 --- /dev/null +++ b/PCbuild/_ssl.mak @@ -0,0 +1,20 @@ + +!IFDEF DEBUG +MODULE=_ssl_d.pyd +TEMP_DIR=x86-temp-debug/_ssl +CFLAGS=/Od /Zi /MDd /LDd /DDEBUG /D_DEBUG +SSL_LIB_DIR=$(SSL_DIR)/out32.dbg +!ELSE +MODULE=_ssl.pyd +TEMP_DIR=x86-temp-release/_ssl +CFLAGS=/Ox /MD /LD +SSL_LIB_DIR=$(SSL_DIR)/out32 +!ENDIF + +INCLUDES=-I ../Include -I ../PC -I $(SSL_DIR)/inc32 +LIBS=gdi32.lib wsock32.lib /libpath:$(SSL_LIB_DIR) libeay32.lib ssleay32.lib + +SOURCE=../Modules/_ssl.c + +$(MODULE): $(SOURCE) ../PC/*.h ../Include/*.h + cl /nologo $(SOURCE) $(CFLAGS) /Fo$(TEMP_DIR)\$*.obj $(INCLUDES) /link /out:$(MODULE) $(LIBS) diff --git a/PCbuild/build_ssl.py b/PCbuild/build_ssl.py new file mode 100644 index 0000000..a1f8004 --- /dev/null +++ b/PCbuild/build_ssl.py @@ -0,0 +1,143 @@ +# Script for building the _ssl module for Windows. +# Uses Perl to setup the OpenSSL environment correctly +# and build OpenSSL, then invokes a simple nmake session +# for _ssl.pyd itself. + +# THEORETICALLY, you can: +# * Unpack the latest SSL release one level above your main Python source +# directory. It is likely you will already find the zlib library and +# any other external packages there. +# * Install ActivePerl and ensure it is somewhere on your path. +# * Run this script from the PCBuild directory. +# +# it should configure and build SSL, then build the ssl Python extension +# without intervention. + +import os, sys, re + +# Find all "foo.exe" files on the PATH. +def find_all_on_path(filename, extras = None): + entries = os.environ["PATH"].split(os.pathsep) + ret = [] + for p in entries: + fname = os.path.abspath(os.path.join(p, filename)) + if os.path.isfile(fname) and fname not in ret: + ret.append(fname) + if extras: + for p in extras: + fname = os.path.abspath(os.path.join(p, filename)) + if os.path.isfile(fname) and fname not in ret: + ret.append(fname) + return ret + +# Find a suitable Perl installation for OpenSSL. +# cygwin perl does *not* work. ActivePerl does. +# Being a Perl dummy, the simplest way I can check is if the "Win32" package +# is available. +def find_working_perl(perls): + for perl in perls: + fh = os.popen(perl + ' -e "use Win32;"') + fh.read() + rc = fh.close() + if rc: + continue + return perl + print "Can not find a suitable PERL:" + if perls: + 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 " Please install ActivePerl and ensure it appears on your path" + print "The Python SSL module was not built" + return None + +# Locate the best SSL directory given a few roots to look into. +def find_best_ssl_dir(sources): + candidates = [] + for s in sources: + try: + s = os.path.abspath(s) + fnames = os.listdir(s) + except os.error: + fnames = [] + for fname in fnames: + fqn = os.path.join(s, fname) + if os.path.isdir(fqn) and fname.startswith("openssl-"): + candidates.append(fqn) + # Now we have all the candidates, locate the best. + best_parts = [] + best_name = None + for c in candidates: + parts = re.split("[.-]", os.path.basename(c))[1:] + # eg - openssl-0.9.7-beta1 - ignore all "beta" or any other qualifiers + if len(parts) >= 4: + continue + if parts > best_parts: + best_parts = parts + best_name = c + if best_name is not None: + print "Found an SSL directory at '%s'" % (best_name,) + else: + print "Could not find an SSL directory in '%s'" % (sources,) + return best_name + +def main(): + debug = "-d" in sys.argv + build_all = "-a" in sys.argv + make_flags = "" + if build_all: + make_flags = "-a" + # perl should be on the path, but we also look in "\perl" and "c:\\perl" + # 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: + sys.exit(1) + + print "Found a working perl at '%s'" % (perl,) + # Look for SSL 2 levels up from pcbuild - ie, same place zlib etc all live. + ssl_dir = find_best_ssl_dir(("../..",)) + if ssl_dir is None: + sys.exit(1) + + old_cd = os.getcwd() + try: + os.chdir(ssl_dir) + # If the ssl makefiles do not exist, we invoke Perl to generate them. + if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \ + not os.path.isfile(os.path.join(ssl_dir, "d32.mak")): + print "Creating the makefiles..." + # Put our working Perl at the front of our path + os.environ["PATH"] = os.path.split(perl)[0] + \ + os.pathsep + \ + os.environ["PATH"] + rc = os.system("ms\\32all.bat") + + # Now run make. + print "Executing nmake over the ssl makefiles..." + if debug: + rc = os.system("nmake /nologo -f d32.mak") + if rc: + print "Executing d32.mak failed" + print rc + sys.exit(rc) + else: + rc = os.system("nmake /nologo -f 32.mak") + if rc: + print "Executing 32.mak failed" + print rc + sys.exit(rc) + finally: + os.chdir(old_cd) + # And finally, we can build the _ssl module itself for Python. + defs = "SSL_DIR=%s" % (ssl_dir,) + if debug: + defs = defs + " " + "DEBUG=1" + rc = os.system('nmake /nologo -f _ssl.mak ' + defs + " " + make_flags) + sys.exit(rc) + +if __name__=='__main__': + main() diff --git a/PCbuild/pcbuild.dsw b/PCbuild/pcbuild.dsw index 25b4a33..b5ef113 100644 --- a/PCbuild/pcbuild.dsw +++ b/PCbuild/pcbuild.dsw @@ -48,6 +48,27 @@ Package=<4> ###############################################################################
+Project: "_ssl"=".\_ssl.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name pythoncore
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name _sre
+ End Project Dependency
+ Begin Project Dependency
+ Project_Dep_Name python
+ End Project Dependency
+}}}
+
+###############################################################################
+
Project: "_symtable"=".\_symtable.dsp" - Package Owner=<4>
Package=<5>
diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt index 94594d0..c662f7b 100644 --- a/PCbuild/readme.txt +++ b/PCbuild/readme.txt @@ -199,7 +199,37 @@ _bsddb.pyd - 0 error(s), 4 warning(s) """ XXX This isn't encouraging, but I don't know what to do about it. +_ssl + Python wrapper for the secure sockets library. + Get the latest source code for OpenSSL from + http://www.openssl.org + + Unpack into the "dist" directory, retaining the folder name from + the archive - for example, the latest stable OpenSSL will install as + dist/openssl-0.9.6g + + You can (theoretically) use any version of OpenSSL you like - the + build process will automatically select the latest version. + + You must also install ActivePerl from + http://www.activestate.com/Products/ActivePerl/ + as this is used by the OpenSSL build process. Complain to them <wink> + + The MSVC project simply invokes PCBuild/build_ssl.py to perform + the build. This Python script locates and builds your OpenSSL + installation, then invokes a simple makefile to build the final .pyd. + + build_ssl.py attempts to catch the most common errors (such as not + being able to find OpenSSL sources, or not being able to find a Perl + that works with OpenSSL) and give a reasonable error message. + If you have a problem that doesn't seem to be handled correctly + (eg, you know you have ActivePerl but we can't find it), please take + a peek at build_ssl.py and suggest patches. Note that build_ssl.py + should be able to be run directly from the command-line. + + build_ssl.py/MSVC isn't clever enough to clean OpenSSL - you must do this + by hand. YOUR OWN EXTENSION DLLs ----------------------- |