Hi all,
First off, let me say how happy I am with Cython. It enables me to
design (parts of) numpy-based algoritms that run at lightning speed! I
keep being amazed at how easy it is to create code with Cython. Keep
up the good work!
However, I just updated to version 1.4 and got a bug.
I compile my code by invoking the compiler from within Python (code
added below). I use the include_dirs option to include the Numpy
header files, and get this error message:
error: Command "gcc -mno-cygwin -O2 -Wall -Wstrict-prototypes -I.
-I"C:\Program Files
(x86)\python26\lib\site-packages\numpy\core\include" -I"C:\Program
Files (x86)\python26\include" -I"C:\Program Files (x86)\python26\PC"
-c convolution1D_.c -o build\temp.win32-2.6\Release\convolution1d_.o
-O" failed with exit status 1
Clearly, there should be a space between the "-I" and the "C:\Pro...".
Thanks,
Almar
PS: When responding to this e-mail, please add me to the CC, since I'm
not a member of this mailing list.
==================
def compile_cython(fname, callerScript=None):
""" compile_cython(fname, callerScript=None)
Compiles the Cython file given by fname.
"""
# Set callerScript if None
if callerScript is None:
callerScript = fname
# Try importing Cython, if not available, return gracefully
try:
from Cython.Distutils import build_ext
except ImportError:
print "Require Cython to compile .pyx files (www.cython.org)."
return
# Store interpreter state
old_argv = sys.argv
old_dir = os.getcwd()
# Prepare state for distutils
sys.argv = [callerScript]
sys.argv.append('build_ext')
sys.argv.append('--inplace')
if sys.platform.startswith('win'):
sys.argv.append('-cmingw32')
#
os.chdir(os.path.dirname(callerScript))
# Get modulename
modNamePlus = os.path.split(fname)[1]
modName = os.path.splitext(modNamePlus)[0]
# Try compiling
try:
# Imports
from distutils.core import setup
from distutils.extension import Extension
from numpy.distutils.misc_util import get_numpy_include_dirs
# Init include dirs
include_dirs = ['.']
# Get numpy headers
include_dirs.extend(get_numpy_include_dirs())
# Create extension module object
ext_modules = [
Extension(modName, [modNamePlus],
include_dirs=include_dirs, extra_compile_args=['-O']),
]
# Compile
setup(
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
)
except BaseException, why: # also catch system exit
print why
raise RuntimeError('SOMETHING WENT WRONG')
else:
print 'Successfully compiled cython file: ', modNamePlus
# Put back the state
sys.argv = old_argv
os.chdir(old_dir)
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev