From 707bfa20734041e781591e981e7cacdfb094a017 Mon Sep 17 00:00:00 2001
From: Christoph Groth <christoph.groth@cea.fr>
Date: Tue, 6 May 2014 11:08:18 +0200
Subject: [PATCH] fix cython version extractions for strings like 0.20.1post0

Thanks to Bas Nijholt for reporting this.
---
 setup.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 873a0498..bbafc619 100755
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,7 @@ TUT_GLOB = 'doc/source/tutorial/*.py'
 TUT_HIDDEN_PREFIX = '#HIDDEN'
 
 import sys
+import re
 import os
 import glob
 import subprocess
@@ -35,8 +36,14 @@ try:
 except:
     cython_version = ()
 else:
-    cython_version = tuple(
-        int(n) for n in Cython.__version__.split('-')[0].split('.'))
+    match = re.match('([0-9.]*)(.*)', Cython.__version__)
+    cython_version = [int(n) for n in match.group(1).split('.')]
+    # Decrease version if the version string contains a suffix.
+    if match.group(2):
+        while cython_version[-1] == 0:
+            cython_version.pop()
+        cython_version[-1] -= 1
+    cython_version = tuple(cython_version)
 
 try:
     sys.argv.remove(NO_CYTHON_OPTION)
-- 
GitLab