Issue #42 new

Recent versions of gevent break __bootstrap__ when packaged

Miguel Turner
created an issue

If you try to package a gevent project (tested with gevent-1.0rc3 on Ubuntu 12) you will will get the following error when the package is run:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/", line 27, in <module>
    exec code in m.__dict__
  File "", line 20, in <module>
    q = queue.Queue()
  File "/usr/local/lib/python2.7/dist-packages/gevent/", line 59, in __init__
    self.hub = get_hub()
  File "/usr/local/lib/python2.7/dist-packages/gevent/", line 169, in get_hub
    hub = _threadlocal.hub = hubtype(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/gevent/", line 268, in __init__
    loop_class = _import(self.loop_class)
  File "/usr/local/lib/python2.7/dist-packages/gevent/", line 198, in _import
    return _import(path[-1])
  File "/usr/local/lib/python2.7/dist-packages/gevent/", line 210, in _import
    x = __import__(module)
  File "", line 22, in <module>
  File "", line 9, in __bootstrap__
AttributeError: 'module' object has no attribute 'path'

After some investigation I found that this happens because cx_Freeze's __bootstrap__ code mistakenly loads gevent's os module, rather than the stdlib's os module.

This can be worked around by changing this line as follows:

import imp, sys
os = sys.modules['os']

I'm not sure this is the best solution, but it works.

Comments (5)

  1. Thomas Kluyver

    Another solution, presumably, would be to use from __future__ import absolute_import. But that only works from Python 2.6, and cx_Freeze is still supporting older versions.

  2. Jake Omann

    The above did not work for me on Python 2.7 in windows. I ended up changing the line:

    import os, imp, sys

    To the following:

    os = __import__("os")
    imp = __import__("imp")
    sys = __import__("sys")

    Which is working fine for me when using gevent.

  3. Log in to comment