File: cython_version_check.patch

package info (click to toggle)
mpi4py 1.3%2Bhg20120611-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,020 kB
  • sloc: python: 9,503; ansic: 6,296; makefile: 571; f90: 158; sh: 146; cpp: 103
file content (49 lines) | stat: -rw-r--r-- 1,969 bytes parent folder | download
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
From: Bradley M. Froehle <brad.froehle@gmail.com>
Subject: Safer Cython version check
 The Cython version check breaks with certain pre-release versions of Cython.
Origin: upstream, http://code.google.com/p/mpi4py/source/detail?r=841e9df9c4a3
Bug: http://code.google.com/p/mpi4py/issues/detail?id=27
--- a/setup.py
+++ b/setup.py
@@ -459,9 +459,10 @@ def run_setup():
           **metadata)
 
 def chk_cython(VERSION):
-    CYTHON_VERSION_REQUIRED = VERSION
+    import re
     from distutils import log
-    from distutils.version import StrictVersion as Version
+    from distutils.version import LooseVersion
+    from distutils.version import StrictVersion
     warn = lambda msg='': sys.stderr.write(msg+'\n')
     #
     cython_zip = 'cython.zip'
@@ -486,17 +487,20 @@ def chk_cython(VERSION):
         CYTHON_VERSION = Cython.__version__
     except AttributeError:
         from Cython.Compiler.Version import version as CYTHON_VERSION
-    CYTHON_VERSION = CYTHON_VERSION.split('+', 1)[0]
-    for s in ('.alpha', 'alpha'):
-        CYTHON_VERSION = CYTHON_VERSION.replace(s, 'a')
-    for s in ('.beta',  'beta', '.rc', 'rc', '.c', 'c'):
-        CYTHON_VERSION = CYTHON_VERSION.replace(s, 'b')
-    if (CYTHON_VERSION_REQUIRED is not None and
-        Version(CYTHON_VERSION) < Version(CYTHON_VERSION_REQUIRED)):
+    REQUIRED = VERSION
+    m = re.match(r"(\d+\.\d+(?:\.\d+)?).*", CYTHON_VERSION)
+    if m:
+        Version = StrictVersion
+        AVAILABLE = m.groups()[0]
+    else:
+        Version = LooseVersion
+        AVAILABLE = CYTHON_VERSION
+    if (REQUIRED is not None and
+        Version(AVAILABLE) < Version(REQUIRED)):
         warn("*"*80)
         warn()
         warn(" You need to install Cython %s (you have version %s)"
-             % (CYTHON_VERSION_REQUIRED, CYTHON_VERSION))
+             % (REQUIRED, CYTHON_VERSION))
         warn(" Download and install Cython <http://www.cython.org>")
         warn()
         warn("*"*80)