[SciPy-dev] weave.inline broken by setuptools?

Fernando Perez fperez.net at gmail.com
Thu Sep 25 23:59:20 EDT 2008


Howdy,

for a scipy workshop I'm going to teach in a few weeks I made a little
checklist in  the form of a nose test suite:

https://cirl.berkeley.edu/fperez/py4science/workshop_checklist.py

I've started getting reports of failures from students using EPD, and
I was finally able to reproduce the problem.  Since I've been known to
launch into unjustified setuptools rants before, I'd like some
guidance from those wiser than me...

If you clean fully your weave cache:

rm -rf ~/.python25_compiled/

and then try running this:

maqroll[~]> cat wsbug.py
from scipy import weave
import setuptools

weave.inline('int x=1;x++;')
# EOF

maqroll[~]> python wsbug.py
<weave: compiling>
Traceback (most recent call last):
  File "wsbug.py", line 4, in <module>
    weave.inline('int x=1;x++;')
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/scipy/weave/inline_tools.py",
line 333, in inline
    **kw)
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/scipy/weave/inline_tools.py",
line 459, in compile_function
    verbose=verbose, **kw)
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/scipy/weave/ext_tools.py",
line 365, in compile
    verbose = verbose, **kw)
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/scipy/weave/build_tools.py",
line 271, in build_extension
    setup(name = module_name, ext_modules = [ext],verbose=verb)
  File "/home/fperez/usr/opt/lib/python2.5/site-packages/numpy/distutils/core.py",
line 184, in setup
    return old_setup(**new_attr)
  File "/usr/lib/python2.5/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.5/distutils/dist.py", line 974, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.5/distutils/dist.py", line 992, in run_command
    cmd_obj = self.get_command_obj(command)
  File "/usr/lib/python2.5/distutils/dist.py", line 869, in get_command_obj
    cmd_obj = self.command_obj[command] = klass(self)
  File "/usr/lib/python2.5/distutils/cmd.py", line 62, in __init__
    raise TypeError, "dist must be a Distribution instance"
TypeError: dist must be a Distribution instance


Doing it in ipython and debugging shows:

TypeError: dist must be a Distribution instance
WARNING: Failure executing file: <wsbug.py>

In [2]: %debug
> /usr/lib/python2.5/distutils/cmd.py(62)__init__()
     61         if not isinstance(dist, Distribution):
---> 62             raise TypeError, "dist must be a Distribution instance"
     63         if self.__class__ is Command:

ipdb> p dist
<numpy.distutils.numpy_distribution.NumpyDistribution instance at 0x90974ec>
ipdb> p Distribution
<class setuptools.dist.Distribution at 0x908b86c>

It seems that all the setuptools monkeypatching is trhrowing
weave/numpy.distutils for a loop.

Any advice?

Note that I found a workaround: importing setuptools *before* weave
makes the problem go away, so for now I have a solution for my
students.  But I think it would be good to know if this is a weave or
a setuptools problem.  It took a while to understand what was going
on, and fixing it might save others some time...

Thanks,

f



More information about the SciPy-Dev mailing list