CFFI attempts to load .py cache file as ELF when extension is installed

Issue #29 resolved
Leonard Ritter
created an issue

I'm running across a strange error when running cffi with pypy, after installing my lib pystbimage with "pypy install" (develop mode works fine). I have seen this error on windows before, and thought it's platform related, but apparently this seems to be some kind of typo - either on CFFI's or my side:


Traceback (most recent call last): File "", line 51, in run_toplevel File "/home/lritter/devel/duangle/beigedemo-0.2/lib-python/2.7/", line 162, in _run_module_as_main "main", fname, loader, pkg_name) File "/home/lritter/devel/duangle/beigedemo-0.2/lib-python/2.7/", line 72, in _run_code exec code in run_globals File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/beige-0.1-py2.7.egg/beige/", line 26, in <module> from .engine import GLEngine File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/beige-0.1-py2.7.egg/beige/engine/", line 21, in <module> from . import texture File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/beige-0.1-py2.7.egg/beige/engine/", line 10, in <module> from stbimage import stbi_load, stbi_flip_y #@UnresolvedImport File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/pystbimage-0.1-py2.7-linux-i686.egg/stbimage/", line 5, in <module> from ._stbimage import * File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/pystbimage-0.1-py2.7-linux-i686.egg/stbimage/", line 56, in <module> _LIB = load_lib(""" File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/pystbimage-0.1-py2.7-linux-i686.egg/stbimage/", line 31, in load_lib """, include_dirs = [CDEF_PATH]) File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/cffi-0.3-py2.7.egg/cffi/", line 281, in verify return self.verifier.load_library() File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/cffi-0.3-py2.7.egg/cffi/", line 62, in load_library return self._load_library() File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/cffi-0.3-py2.7.egg/cffi/", line 134, in _load_library return self._vengine.load_library() File "/home/lritter/devel/duangle/beigedemo-0.2/site-packages/cffi-0.3-py2.7.egg/cffi/", line 47, in load_library module = backend.load_library(self.verifier.modulefilename) OSError: cannot load '/home/lritter/devel/duangle/beigedemo-0.2/site-packages/pystbimage-0.1-py2.7-linux-i686.egg/': /home/lritter/devel/duangle/beigedemo-0.2/site-packages/pystbimage-0.1-py2.7-linux-i686.egg/ invalid ELF header }}}

My ( doesn't look particularly odd, so I wonder what could be wrong here?

Comments (9)

  1. Armin Rigo

    Who comes up with such a name in the first place? I thought that the name prefix "_cffi_*" was only used with the extensions ".c" or ".so". It doesn't make sense with the extension ".py"...

  2. Armin Rigo

    What is in this file in the first place? Maybe it's some egg magic that replaces .so files with .py files that locate and load the .so? In other words, can you paste the content of this .py file?

    Such magic is bound to break obscure cases (like the one here, but not only). Well, you never know. I would be surprized if there was such magic, but after all it would just be yet another over-the-top behavior of installing schemes of Python :-(

  3. Armin Rigo

    Ok, found out that you need (as a workaround) to put the following line in your, as an extra argument to the setup() function:

  4. Leonard Ritter reporter

    This is what's in the file (you probably have seen this already)

    def __bootstrap__():
       global __bootstrap__, __loader__, __file__
       import sys, pkg_resources, imp
       __file__ = pkg_resources.resource_filename(__name__,'')
       __loader__ = None; del __bootstrap__, __loader__

    Adding the zip_safe=False argument did not change anything for pypy - leaving it out also made no change; it's still creating the fake importer.

  5. Log in to comment