[Pyrex] Conditional Compilation
Simon King
king at mathematik.uni-jena.de
Sun Oct 14 19:39:10 CEST 2007
Dear Pyrex group,
in
http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/basics.html#Conditional_Compilation
i found that Pyrex 0.9.6 supports compile-time definitions and
conditional compilation.
However, i didn't succeed to make it work, so far. Perhaps you can help
me?
According to an example in the above link, i have a file "test.pyx"
containing:
IF UNAME_SYSNAME == "Linux":
def x():
print "It works!"
ELSE:
def x():
print "Doesn't work"
However, pyrexc 0.9.6.2 (which is in my /usr/local/bin/) complains a lot:
Traceback (most recent call last):
File "/usr/local/bin/pyrexc", line 8, in <module>
main(command_line = 1)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Main.py",
line 312, in main
result = context.compile(source, options)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Main.py",
line 188, in compile
tree = self.parse(source, scope.type_names, pxd = 0)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Main.py",
line 142, in parse
tree = Parsing.p_module(s, pxd)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Parsing.py",
line 1944, in p_module
body = p_statement_list(s, level)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Parsing.py",
line 1252, in p_statement_list
cdef_flag = cdef_flag, visibility = visibility, api = api))
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Parsing.py",
line 1201, in p_statement
return p_IF_statement(s, level, cdef_flag, visibility, api)
File "/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/Parsing.py",
line 1173, in p_IF_statement
s.compile_time_eval = current_eval and
bool(expr.compile_time_value(denv))
File
"/usr/local/lib/python2.5/site-packages/Pyrex/Compiler/ExprNodes.py", line
2923, in compile_time_value
operand1 = self.operand.compile_time_value(denv)
AttributeError: PrimaryCmpNode instance has no attribute 'operand'
Can you explain to me what i did wrong?
Perhaps there was a path missing when i built pyrex: I work on 32/64 bit
(x86_64), but there is only a /usr/local/lib/python2.5/, but no
/usr/local/lib64/python2.5/
Can this be the reason? And how to fix it?
Yours
Simon King
More information about the Pyrex
mailing list