summaryrefslogtreecommitdiff
blob: 9b7c03baf93c0161aab2f96efa3f088e103218e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
* make GMP conditional
* don't use hardwired search path /lib /usr/lib, but instead use the
  python configured libdir (in particular under Prefix very important,
  e.g. bug #291949)

--- setup.py
+++ setup.py
@@ -36,7 +36,7 @@
 
 __revision__ = "$Id: pycrypto-2.1.0-gmp.patch,v 1.2 2009/12/23 21:56:41 grobian Exp $"
 
-from distutils import core
+from distutils import core, sysconfig
 from distutils.core import Extension, Command
 from distutils.command.build_ext import build_ext
 import os, sys
@@ -151,11 +151,12 @@
         if self.compiler.compiler_type == 'msvc':
             self.compiler.include_dirs.insert(0, "src/inc-msvc/")
 
-        # Detect libgmp and don't build _fastmath if it is missing.
-        lib_dirs = self.compiler.library_dirs + ['/lib', '/usr/lib']
-        if not (self.compiler.find_library_file(lib_dirs, 'gmp')):
-            print >>sys.stderr, "warning: GMP library not found; Not building Crypto.PublicKey._fastmath."
-            self.__remove_extensions(["Crypto.PublicKey._fastmath"])
+        if os.environ.get("USE_GMP", "1") == "1":
+            # Detect libgmp and don't build _fastmath if it is missing.
+            lib_dirs = self.compiler.library_dirs + [sysconfig.get_config_var('LIBDIR'), '/lib', '/usr/lib']
+            if not (self.compiler.find_library_file(lib_dirs, 'gmp')):
+                print >>sys.stderr, "error: GMP library not found."
+                sys.exit(1)
 
     def __remove_extensions(self, names):
         """Remove the specified extension from the list of extensions to build"""