From f3c8e63e57278ce98c54bc4752a425bce784ba46 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Sun, 12 Apr 2020 07:13:18 -0400 Subject: [PATCH 1/2] Allow setup.py --version to run without Cython, numpy --- setup.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index a7c98db..bbb4739 100755 --- a/setup.py +++ b/setup.py @@ -1,12 +1,16 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst from setuptools import setup, Extension -import numpy as np -from Cython.Build import cythonize +try: + from Cython.Build import cythonize + import numpy as np + fastss_ext = Extension("Ska.Numpy.fastss", + ['Ska/Numpy/fastss.pyx'], + include_dirs=[np.get_include()]) +except ImportError: + cythonize = lambda arg: None + fastss_ext = None -fastss_ext = Extension("Ska.Numpy.fastss", - ['Ska/Numpy/fastss.pyx'], - include_dirs=[np.get_include()]) try: from testr.setup_helper import cmdclass except ImportError: From cc5edb4266e542b3f41fc11f5729bf01f296fdf0 Mon Sep 17 00:00:00 2001 From: Tom Aldcroft Date: Thu, 16 Apr 2020 09:29:33 -0400 Subject: [PATCH 2/2] Change logic to fail when appropriate --- setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index bbb4739..249933f 100755 --- a/setup.py +++ b/setup.py @@ -1,15 +1,18 @@ # Licensed under a 3-clause BSD style license - see LICENSE.rst +import sys from setuptools import setup, Extension -try: +# Special case here to allow `python setup.py --version` to run without +# requiring cython and numpy to be installed. +if '--version' in sys.argv[1:]: + cythonize = lambda arg: None + fastss_ext = None +else: from Cython.Build import cythonize import numpy as np fastss_ext = Extension("Ska.Numpy.fastss", ['Ska/Numpy/fastss.pyx'], include_dirs=[np.get_include()]) -except ImportError: - cythonize = lambda arg: None - fastss_ext = None try: from testr.setup_helper import cmdclass