Add support for msvc
authorGiannis Adamopoulos <johnyadams@outlook.com>
Sun, 19 Oct 2014 15:03:31 +0000 (18:03 +0300)
committerKali Kaneko <kali@leap.se>
Mon, 10 Nov 2014 22:23:22 +0000 (23:23 +0100)
setup.py

index 6f2f6cb..a8a2531 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -180,7 +180,24 @@ class MyBuildExt(build_ext):
             ext.sources.append(os.path.join(AMALGAMATION_ROOT, "sqlite3.c"))
             ext.include_dirs.append(AMALGAMATION_ROOT)
 
-            ext.extra_link_args.append("-lcrypto")
+            if sys.platform == "win32":
+                # Try to locate openssl
+                openssl_conf = os.environ.get('OPENSSL_CONF')
+                if not openssl_conf:
+                    sys.exit('Fatal error: OpenSSL could not be detected!') 
+                openssl = os.path.dirname(os.path.dirname(openssl_conf))
+
+                # Configure the compiler
+                ext.include_dirs.append(os.path.join(openssl, "include"))
+                ext.define_macros.append(("inline", "__inline"))
+
+                # Configure the linker
+                ext.extra_link_args.append("libeay32.lib")
+                ext.extra_link_args.append(
+                    "/LIBPATH:" + os.path.join(openssl, "lib")
+                )
+            else:
+                ext.extra_link_args.append("-lcrypto")
 
         if self.static:
             self._build_extension(ext)