setup.py patch

Matthew Rodriguez DSD staff <[email protected]>
Newsgroups gmane.comp.python.cryptography
Message-ID <[email protected]>
Here is the patch to pass an openssl location.

Matt Rodriguez
setup.py.3rd.patch (text/x-patch, 1.8 KB)
--- setup.py.orig	2005-11-07 15:45:52.000000000 -0800
+++ setup.py	2005-11-07 15:44:55.000000000 -0800
@@ -15,6 +15,30 @@
 from distutils.core import setup, Extension
 from distutils.command import build_ext
 
+global_option_dict = {'openssl_prefix': '/usr'}
+
+def print_help():
+    print "M2Crypto help"
+    print "--openssl=path_to_openssl, defaults to /usr"
+    print "--help, this usage message"
+
+def parse_args():
+    global global_option_dict
+    args = sys.argv[1:]
+    for arg in args:
+        if arg.find("--openssl") != -1:
+            sys.argv.remove(arg)
+            prefix = arg.split('=')[1]
+            global_option_dict['openssl_prefix'] = prefix
+
+        if arg.find("--help") != -1:
+            sys.argv.remove(arg)
+            print_help()
+            sys.exit(0)
+
+parse_args()
+
+                    
 my_inc = os.path.join(os.getcwd(), 'SWIG')
 
 if os.name == 'nt':
@@ -25,8 +49,11 @@
     libraries = ['ssleay32', 'libeay32']
     
 elif os.name == 'posix':
-    include_dirs = [my_inc, '/usr/include']
-    swig_opts_str = '-I/usr/include'
+    include_dir = os.path.join(global_option_dict['openssl_prefix'], "include")
+    include_dirs = [my_inc, include_dir]
+    library_dir = os.path.join(global_option_dict['openssl_prefix'], "lib")
+    library_dirs = [library_dir] 
+    swig_opts_str = "-I" + include_dir
     library_dirs = ['/usr/lib']
     if sys.platform == 'cygwin':
         # Cygwin SHOULD work (there's code in distutils), but
@@ -77,7 +104,10 @@
             return new_sources
 
         swig = self.find_swig()
-        swig_cmd = [swig, "-python", "-ISWIG"]
+        include_dir = os.path.join(
+                      global_option_dict['openssl_prefix'], 
+                      "include")
+        swig_cmd = [swig, "-python", "-ISWIG"] 
         if self.swig_cpp:
             swig_cmd.append("-c++")
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.