summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2019-09-02 08:31:47 -0600
committerCharles Harris <charlesr.harris@gmail.com>2019-09-02 08:31:47 -0600
commit393a3a452e0f1b96f3c44e0bd0a5d9085dd139aa (patch)
treec5cbf3b3a6c0a43ff6c2260e2a4939256510d147
parent6177cbef142ba478646c472c18f69962e0682ef6 (diff)
downloadnumpy-393a3a452e0f1b96f3c44e0bd0a5d9085dd139aa.tar.gz
MAINT: Only allow using Cython module when cythonizing.
The command line version of `cython` may point to a different installation of Cython than that installed in the Python running the cythonize script. Because the Cython version can be critical, requiring that the cython used comes from a known place makes it less likely that the wrong version will be used. This treats Cython as a build dependency rather than a free standing compiler.
-rwxr-xr-xtools/cythonize.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/tools/cythonize.py b/tools/cythonize.py
index 8b2f5b519..d41c3270b 100755
--- a/tools/cythonize.py
+++ b/tools/cythonize.py
@@ -60,13 +60,10 @@ def process_pyx(fromfile, tofile):
# try the cython in the installed python first (somewhat related to scipy/scipy#2397)
from Cython.Compiler.Version import version as cython_version
except ImportError:
- # if that fails, use the one on the path, which might be the wrong version
- try:
- # Try the one on the path as a last resort
- subprocess.check_call(
- ['cython'] + flags + ["-o", tofile, fromfile])
- except OSError:
- raise OSError('Cython needs to be installed')
+ # The `cython` command need not point to the version installed in the
+ # Python running this script, so raise an error to avoid the chance of
+ # using the wrong version of Cython.
+ raise OSError('Cython needs to be installed in Python as a module')
else:
# check the version, and invoke through python
from distutils.version import LooseVersion