From 18707662284b84568c1b6c115d2f4b8cf08bbca2 Mon Sep 17 00:00:00 2001 From: Matthew Einhorn Date: Mon, 16 Feb 2015 23:24:57 -0500 Subject: [PATCH] Use distutils for cython version comparision. --- setup.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index 37790bc3c..9ad29f370 100644 --- a/setup.py +++ b/setup.py @@ -3,11 +3,6 @@ # http://kivy.org/ # -MIN_CYTHON_VERSION = (0, 20, 0) -MIN_CYTHON_STRING = '.'.join(map(str, MIN_CYTHON_VERSION)) -MAX_CYTHON_VERSION = (0, 21, 1) -MAX_CYTHON_STRING = '.'.join(map(str, MAX_CYTHON_VERSION)) - import sys from copy import deepcopy @@ -16,8 +11,15 @@ from os.path import join, dirname, sep, exists, basename from os import walk, environ from distutils.core import setup from distutils.extension import Extension +from distutils.version import LooseVersion from collections import OrderedDict + +MIN_CYTHON_STRING = '0.20.0' +MIN_CYTHON_VERSION = LooseVersion(MIN_CYTHON_STRING) +MAX_CYTHON_STRING = '0.21.1' +MAX_CYTHON_VERSION = LooseVersion(MAX_CYTHON_STRING) + if sys.version > '3': PY3 = True else: @@ -112,13 +114,13 @@ else: have_cython = True import Cython cy_version_str = Cython.__version__ - cy_version = tuple(map(int, cy_version_str.split('.'))) + cy_ver = LooseVersion(cy_version_str) print('\nDetected Cython version {}'.format(cy_version_str)) - if cy_version < MIN_CYTHON_VERSION: + if cy_ver < MIN_CYTHON_VERSION: print(' This version of Cython is not compatible with Kivy. ' + 'Please upgrade to at least {}'.format(MIN_CYTHON_STRING)) raise ImportError('Incompatible Cython Version') - if cy_version > MAX_CYTHON_VERSION: + if cy_ver > MAX_CYTHON_VERSION: print(' This version of Cython is untested with Kivy. If you ' + 'experience issues, please downgrade to {}' .format(MAX_CYTHON_STRING))