Re: Problem with ValueError: <classname> has the wrong size, try recompiling
Robert Bradshaw <robertwb <at> math.washington.edu>
2011-08-04 08:37:56 GMT
On Thu, Aug 4, 2011 at 1:31 AM, santa <gerald.senarclens <at> gmail.com> wrote:
> Hi,
> thanks for your answer! I just upgraded to the current version of cython to
> make sure I have a working cythonize (w/ sudo pip install cython
> --upgrade).
> cython --version yields Cython version 0.14.1
>>
>> Recompile all your .pyx files again (you can force this by removing
>>
>> all your .c files)
>
> Doesn't work when removing all .c, .o and .so files and then directly
> calling setup.py afterwards; same issue. Manually cythonizing the pyx files
> first (cython *.pyx) and then calling the old setup works like a charm. :)
Removing the .c files should cause it to create new ones as if you did
it manually. Are you sure you didn't have some old object files cached
somewhere? Are you invoking the same version of Cython from setup.py
as you are from the command line?
>> or use a setup like
>> http://wiki.cython.org/enhancements/distutils_preprocessing that
>> understands interdependencies.
>
> Using the exact setup.py script proposed in your link (with cython 0.14.1),
> I get the following:
> <terminal>
> ~/bitbucket/c_test >python setup.py build_ext --inplace
> Traceback (most recent call last):
> File "setup.py", line 6, in <module>
> ext_modules = cythonize(["*.pyx"]),
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 456, in cythonize
> aliases=aliases)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 426, in create_extension_list
> pkg = deps.package(file)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 21, in wrapper
> res = cache[args] = f(self, *args)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 287, in package
> return self.package(dir) + (os.path.basename(dir),)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 21, in wrapper
> res = cache[args] = f(self, *args)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 287, in package
> return self.package(dir) + (os.path.basename(dir),)
> ... # removed a few hundred repeating lines
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 287, in package
> return self.package(dir) + (os.path.basename(dir),)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 21, in wrapper
> res = cache[args] = f(self, *args)
> File
> "/usr/local/lib/python2.7/dist-packages/Cython/Build/Dependencies.py", line
> 286, in package
> if os.path.exists(os.path.join(dir, '__init__.py')):
> File "/usr/lib/python2.7/posixpath.py", line 68, in join
> elif path == '' or path.endswith('/'):
> RuntimeError: maximum recursion depth exceeded in cmp
> </terminal>
Hmm... I'll take a look at that. Could you re-post your code so I can
try to reproduce it?
>>
>> The long answer:
>>
>> You have node.pyx, node.pxd, problemreader.pyx. When compiling
>> problemreader.pyx it looks at node.pxd and uses information about
>> object struct layouts, etc. to generate the .c file.
>
> ok
>>
>> If you then
>> modify node.pxd without re-compiling problemreader.pyx the C-level
>> layout of your Node class can change rendering it incompatible with
>> problemreader.c. Cython detects this at runtime (when it can) and
>> trows this value error.
>
> I think this would be much easier to understand if I actually modified
> anything... but the problem occurs on executing the setup script on a
> version without any c etc. files. Everything is generated, then nothing is
> changed and the error still occurs. Would be nice to be able to understand
> this, however I'm happy that I have now one way of creating everything that
> doesn't fail (manually cythonizing the .pyx files and then calling the old
> setup). I guess whatever goes wrong with the new setup script deserves a
> look as well - do you want me to file a bug? [1]
> /gerald
> [1] I couldn't find any related bug on http://trac.cython.org.
Yes, please do.
- Robert