[Cython] Cython 0.16: problems with "easy_install"

2012-04-21 Thread Nathan Dunfield
Dear all,

On OS X Snow Leopard with XCode 3.2.*, I encountered the following issues when 
using "easy_install" to install the new Cython 0.16:

(a) With Python 2.7 where Cython 0.15.1 had previously been installed, 
"easy_install" failed with the below error message; looks like it's somehow 
using the existing Cython for part of the compilation and then failing.  After 
I deleted the existing egg in site-packages it easy_installed fine.

(b) With Python 3.2 and no Cython installed in site-packages, it chokes with 
the following error:

haken ~ (8) py3 -m easy_install -U cython
Searching for cython
Reading http://pypi.python.org/simple/cython/
Couldn't find index page for 'cython' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Reading http://pypi.python.org/simple/Cython/
Reading http://www.cython.org
Reading http://cython.org
Best match: Cython 0.16
Downloading http://www.cython.org/release/Cython-0.16.zip
Processing Cython-0.16.zip
Running Cython-0.16/setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-ers4by/Cython-0.16/egg-dist-tmp-a6gz6a
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
warning: no files found matching '*.h' under directory 'Cython/Utility'
warning: no files found matching '.cpp' under directory 'Cython/Utility'
i686-apple-darwin10-gcc-4.2.1: 
/tmp/easy_install-ers4by/Cython-0.16/Cython/Runtime/refnanny.c: No such file or 
directory
i686-apple-darwin10-gcc-4.2.1: no input files
i686-apple-darwin10-gcc-4.2.1: 
/tmp/easy_install-ers4by/Cython-0.16/Cython/Runtime/refnanny.c: No such file or 
directory
i686-apple-darwin10-gcc-4.2.1: no input files
lipo: can't figure out the architecture type of: /var/tmp//ccvgdiS6.out
error: Setup script exited with error: command 'gcc' failed with exit status 1

If I download the .zip file and run setup.py by hand it installs fine.  

Best,

Nathan

Error when easy_installing with Python 2.7:

haken ~ (1) py -m easy_install -U cython
Searching for cython
Reading http://pypi.python.org/simple/cython/
Reading http://www.cython.org
Reading http://cython.org
Best match: Cython 0.16
Downloading http://www.cython.org/release/Cython-0.16.zip
Processing Cython-0.16.zip
Running Cython-0.16/setup.py -q bdist_egg --dist-dir 
/tmp/easy_install-1x8vwP/Cython-0.16/egg-dist-tmp-dx99kU
Compiling module Cython.Plex.Scanners ...
Compiling module Cython.Plex.Actions ...
Compiling module Cython.Compiler.Lexicon ...
Compiling module Cython.Compiler.Scanning ...
Compiling module Cython.Compiler.Parsing ...
Compiling module Cython.Compiler.Visitor ...

Error compiling Cython file:

...
   raise Errors.CompilerCrash(
   getattr(last_node, 'pos', None), self.__class__.__name__,
   u'\n'.join(trace), e, stacktrace)

   @cython.final
   def find_handler(self, obj):
  ^


/tmp/easy_install-1x8vwP/Cython-0.16/Cython/Compiler/Visitor.py:138:4: The 
final compiler directive is not allowed in function scope

Error compiling Cython file:

...

   def visit(self, obj):
   return self._visit(obj)

   @cython.final
   def _visit(self, obj):
  ^


/tmp/easy_install-1x8vwP/Cython-0.16/Cython/Compiler/Visitor.py:159:4: The 
final compiler directive is not allowed in function scope

Error compiling Cython file:

...
   handler_method = self.find_handler(obj)
   self.dispatch_table[type(obj)] = handler_method
   return handler_method(obj)

   @cython.final
   def _visitchild(self, child, parent, attrname, idx):
  ^


/tmp/easy_install-1x8vwP/Cython-0.16/Cython/Compiler/Visitor.py:168:4: The 
final compiler directive is not allowed in function scope

Error compiling Cython file:

...

   def visitchildren(self, parent, attrs=None):
   return self._visitchildren(parent, attrs)

   @cython.final
   def _visitchildren(self, parent, attrs):
  ^


/tmp/easy_install-1x8vwP/Cython-0.16/Cython/Compiler/Visitor.py:192:4: The 
final compiler directive is not allowed in function scope
Compilation failed


___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


[Cython] Cython 0.16: "eval" problem

2012-04-22 Thread Nathan Dunfield
With Cython 0.15, the following works with Python 2.7:

### start file: prob.pyx

def f(x):
cdef int* p
return eval(x)

### end file

>>> import pyximport; pyximport.install()
>>> import prob
>>> prob.f("5")
5

but with Cython 0.16 it doesn't even compile:

>>> import prob

Error compiling Cython file:

...
def f(x):
cdef int* p
return eval(x)
  ^


prob.pyx:3:15: Cannot convert 'int *' to Python object

If I comment out the (unused) line "cdef int* p" then it works with Cython 
0.16.  The issue is the pointer declaration; something like:

def f(x):
cdef int p
p = eval(x)
return p*p

works fine with Cython 0.16.

Thanks,

Nathan





___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Cython 0.16: "eval" problem

2012-04-22 Thread Nathan Dunfield
On Apr 22, 2012, at 1:22 PM, Vitja Makarov wrote:
> Oops, it seems to be a problem with locals() dict creation. 

Yes it does.   The following variants of my original example both work:

## prob.pyx version 1

def cy_eval(s):
return eval(s)

def f(x):
cdef int* p
return cy_eval(x)

## prob.pyx version 2

def f(x):
cdef int* p
return eval(x, {})

Best,

Nathan

___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


[Cython] Cython 0.16 issue Windows with Mingw32

2012-04-23 Thread Nathan Dunfield
I've encountered the following issue with Cython 0.16 on Windows with using the 
Mingw32 compiler (I'm using Python 3.2 here, but I don't think that's the 
issue):

$ python3 setup.py build -c mingw32
running build
running build_py
running build_ext
skipping 'SnapPy.c' Cython extension (up-to-date)
building 'snappy.SnapPy' extension
c:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Iheaders -Iunix_kit 
-Iaddl_code -I. -Ipari/pari-2.3.4/include/ -Ipari/pari-2.3.4/include/pari 
-Ic:\Python32\include -Ic:\Python32\PC -c SnapPy.c -o 
build\temp.win32-3.2\Release\snappy.o
SnapPy.c: In function 
`__pyx_f_6snappy_6SnapPy_13Triangulation_build_rep_into_Sn':
SnapPy.c:25187: warning: implicit declaration of function `fg_get_num_orig_gens'
SnapPy.c:25423: warning: implicit declaration of function `candidateSn_is_valid'
SnapPy.c:25435: warning: implicit declaration of function 
`candidateSn_is_transitive'
SnapPy.c: At top level:
SnapPy.c:76434: error: initializer element is not constant
SnapPy.c:76434: error: (near initialization for 
`__pyx_CyFunctionType_type.tp_call')
error: command 'gcc' failed with exit status 1

The problem seems to be in the code that's pulled in from CythonFunction.c.   I 
apologize for not providing a more minimal example (the above code is available 
at "hg clone static-http://math.uic.edu/t3m/hg/SnapPy";) but the small module I 
tried didn't pull in the CythonFunction.c code. 

Thanks,

Nathan


___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel


Re: [Cython] Cython 0.16 issue Windows with Mingw32

2012-04-24 Thread Nathan Dunfield
On Apr 23, 2012, at 1:28 PM, Stefan Behnel wrote:
> Hmm, that line basically just says "PyCFunction_Call", which is a function
> exported by CPython. I wonder why gcc would consider this "not a constant".
> 
> Could you check if the preprocessor (gcc -E, with all the above includes)
> also sees that on your side?

It turns out I was running a version of MinGW that, while only a few years old, 
had a quite elderly version of gcc, namely 3.4 (yes, that's 3.4 and not 4.3).   
Once I updated to the most recent MinGW, which has gcc 4.6, and worked around a 
known bug in distutils ( http://bugs.python.org/issue12641 ), the issue with 
PyCFunction_Call went away and the entire 76k line Cython generated C file 
compiled without a hitch.  So probably this is only a problem on very old 
compilers, and so perhaps not worth investigating further.

Best,

Nathan




___
cython-devel mailing list
cython-devel@python.org
http://mail.python.org/mailman/listinfo/cython-devel