View | Details | Raw Unified | Return to bug 172299
Collapse All | Expand All

(-)./Makefile (-5 / +25 lines)
Lines 15-31 Link Here
15
MAINTAINER=	jgh@FreeBSD.org
15
MAINTAINER=	jgh@FreeBSD.org
16
COMMENT=	The Python Cryptography Toolkit
16
COMMENT=	The Python Cryptography Toolkit
17
17
18
USE_PYTHON=	yes
18
USE_PYTHON=		yes
19
USE_PYDISTUTILS=yes
19
USE_PYDISTUTILS=	yes
20
20
21
HAS_CONFIGURE=	yes
21
HAS_CONFIGURE=	yes
22
USE_AUTOTOOLS=	autoconf
22
USE_AUTOTOOLS=	autoconf
23
CPPFLAGS+=	-I${LOCALBASE}/include
24
LDFLAGS+=	-L${LOCALBASE}/lib
25
23
26
LIB_DEPENDS+=	gmp.10:${PORTSDIR}/math/gmp
24
OPTIONS_DEFINE=		GMP
25
OPTIONS_DEFAULT=	GMP
26
GMP_DESC=		Use GMP for faster DSA/RSA operations
27
28
OPTIONSFILE?=		${PORT_DBDIR}/py-${PORTNAME}/options
29
30
.include <bsd.port.options.mk>
31
32
.if ${PORT_OPTIONS:MGMP}
33
LIB_DEPENDS+=		gmp:${PORTSDIR}/math/gmp
34
CONFIGURE_ARGS+=	--with-gmp
35
CPPFLAGS+=		-I${LOCALBASE}/include
36
LDFLAGS+=		-L${LOCALBASE}/lib
37
PLIST_SUB+=		GMP=""
38
.else
39
CONFIGURE_ARGS+=	--without-gmp
40
PLIST_SUB+=		GMP="@comment "
41
.endif
27
42
28
pre-patch:
43
pre-patch:
29
	@${REINPLACE_CMD} -e "s|%%LOCALBASE%%|${LOCALBASE}|" ${WRKSRC}/setup.py
44
	@${REINPLACE_CMD} -e "s|%%LOCALBASE%%|${LOCALBASE}|" ${WRKSRC}/setup.py
30
45
46
test: build
47
	cd ${WRKSRC} && ${PYTHON_CMD} ${PYSETUP} test
48
49
regression-test: test
50
31
.include <bsd.port.mk>
51
.include <bsd.port.mk>
(-)./files/patch-lib__Crypto__SelfTest__Util__test_number.py (+37 lines)
Line 0 Link Here
1
--- ./lib/Crypto/SelfTest/Util/test_number.py.orig	2012-10-03 16:03:52.000000000 +1000
2
+++ ./lib/Crypto/SelfTest/Util/test_number.py	2012-10-03 16:04:01.000000000 +1000
3
@@ -276,6 +276,11 @@
4
         self.assertEqual(number.size(0xa2ba40),8*3)
5
         self.assertEqual(number.size(0xa2ba40ee07e3b2bd2f02ce227f36a195024486e49c19cb41bbbdfbba98b22b0e577c2eeaffa20d883a76e65e394c69d4b3c05a1e8fadda27edb2a42bc000fe888b9b32c22d15add0cd76b3e7936e19955b220dd17d4ea904b1ec102b2e4de7751222aa99151024c7cb41cc5ea21d00eeb41f7c800834d2c6e06bce3bce7ea9a5L), 1024)
6
 
7
+class FastmathTests(unittest.TestCase):
8
+    def setUp(self):
9
+        global number
10
+        from Crypto.Util import number
11
+
12
     def test_negative_number_roundtrip_mpzToLongObj_longObjToMPZ(self):
13
         """Test that mpzToLongObj and longObjToMPZ (internal functions) roundtrip negative numbers correctly."""
14
         n = -100000000000000000000000000000000000L
15
@@ -286,7 +291,21 @@
16
 
17
 def get_tests(config={}):
18
     from Crypto.SelfTest.st_common import list_test_cases
19
-    return list_test_cases(MiscTests)
20
+    tests = list_test_cases(MiscTests)
21
+    try:
22
+        from Crypto.PublicKey import _fastmath
23
+        tests += list_test_cases(FastmathTests)
24
+    except ImportError:
25
+        from distutils.sysconfig import get_config_var
26
+        import inspect, os.path
27
+        _fm_path = os.path.normpath(os.path.dirname(os.path.abspath(
28
+            inspect.getfile(inspect.currentframe())))
29
+            +"/../../PublicKey/_fastmath"+get_config_var("SO"))
30
+        if os.path.exists(_fm_path):
31
+            raise ImportError("While the _fastmath module exists, importing "+
32
+                "it failed. This may point to the gmp or mpir shared library "+
33
+                "not being in the path. _fastmath was found at "+_fm_path)
34
+    return tests
35
 
36
 if __name__ == '__main__':
37
     suite = lambda: unittest.TestSuite(get_tests())
(-)./files/patch-setup.py (-3 / +3 lines)
Lines 1-6 Link Here
1
--- setup.py.orig	2011-11-01 17:47:23.000000000 +0400
1
--- ./setup.py.orig	2012-10-03 15:57:50.000000000 +1000
2
+++ setup.py	2011-11-01 17:54:51.000000000 +0400
2
+++ ./setup.py	2012-10-03 15:57:50.000000000 +1000
3
@@ -177,6 +177,7 @@
3
@@ -136,6 +136,7 @@
4
                 # especially helps the DES modules.
4
                 # especially helps the DES modules.
5
                 self.__add_compiler_option("-O3")
5
                 self.__add_compiler_option("-O3")
6
                 self.__add_compiler_option("-fomit-frame-pointer")
6
                 self.__add_compiler_option("-fomit-frame-pointer")
(-)./pkg-plist (-1 / +1 lines)
Lines 115-121 Link Here
115
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.py
115
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.py
116
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyc
116
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyc
117
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyo
117
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/__init__.pyo
118
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_fastmath.so
118
%%GMP%%%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_fastmath.so
119
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.py
119
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.py
120
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyc
120
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyc
121
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyo
121
%%PYTHON_SITELIBDIR%%/Crypto/PublicKey/_slowmath.pyo

Return to bug 172299