KeyError: '_speedups'

Brett Cannon avatarBrett Cannon created an issue

I tried to install Sphinx using ``easy_install -U Sphinx`` and while trying to install Jinja an exception is thrown::

File "/Users/brett/.local/lib/python2.6/site-packages/distribute-0.6.1-py2.6.egg/setuptools/command/build_ext.py", line 85, in get_ext_filename ext = self.ext_map[fullname] KeyError: '_speedups'

Looks like something about trying to build extensions is failing. This is Python 2.6.2+, non-framework on OS X 10.6 using Distribute 0.6.1.

Comments (6)

  1. Tarek Ziadé

    That's strange because Jinja provides its own build_ext command in its setup.py file, that does the work, by calling distutils's build_ext command and dealing with compile errors.

    I couldn't reproduce that problem (I am on Mac OS X Leopard - py2.6).

    Do you still have the full traceback by any chance ?

  2. Tarek Ziadé
    • changed status to open

    Ok thanks, I've found the problem.

    Here's the explanation, I hope it's not too complex to understand:

    Distribute (well Setuptools in fact) overrides Distutils 'get_ext_filename' which is suppose to return a path. But in this implementation, it does a lot more and makes the assumption that the provided argument *is* an extension name and *is* a fullname. (if you look at setuptools code, it even changed the argument name to "fullname", when it's called "ext_name" in Distutils)

    Distribute uses in this method self.ext_map which is filled properly *only* when the method is called with an extension fullname.

    Unfortunately, Distutils uses this function since 2.6.2 in another context to get a filename that is not a fullname (yes you can ;) ), so if Distribute is present, it will break.

    The solution is to keep this method returning what it is suppose to return and not making such assumptions. A refactoring is required on Distribute side, to make it work properly

    Unfortunately, starting at 2.6.2, people that compile extensions using the Setuptools project will have this problem.

    A quick fix is:

    $ hg di setuptools/command/build_ext.py
    diff -r 48c7bb55039e setuptools/command/build_ext.py
    --- a/setuptools/command/build_ext.py   Sat Sep 12 09:06:05 2009 +0200
    +++ b/setuptools/command/build_ext.py   Sun Sep 13 00:07:57 2009 +0200
    @@ -82,6 +82,8 @@
     
         def get_ext_filename(self, fullname):
             filename = _build_ext.get_ext_filename(self,fullname)
    +        if fullname not in self.ext_map:
    +            return filename
             ext = self.ext_map[fullname]
             if isinstance(ext,Library):
                 fn, ext = os.path.splitext(filename)
    

    I doubt that Setuptools itself will be fixed then released, but this problem will be fixed in Distribute 0.6.2.

  3. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.