• Kirill Smelkov's avatar
    gpython: Fix gevent activation on Windows · f23a9ef5
    Kirill Smelkov authored
    On Windows if geventmp is present gpython startup fails:
    
        (1.wenv) Z:\home\kirr\src\tools\go\pygo-win\pygolang>gpython
        Traceback (most recent call last):
          File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
            return _run_code(code, main_globals, None,
          File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
            exec(code, run_globals)
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\Scripts\gpython.exe\__main__.py", line 7, in <module>
          File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 450, in main
            pymain(argv, init)
          File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 223, in pymain
            init()
          File "Z:\home\kirr\src\tools\go\pygo-win\pygolang\gpython\__init__.py", line 428, in init
            _ = monkey.patch_all(thread=patch_thread)      # XXX sys=True ?
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\gevent\monkey.py", line 1255, in patch_all
            _notify_patch(events.GeventWillPatchAllEvent(modules_to_patch, kwargs), _warnings)
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\gevent\monkey.py", line 190, in _notify_patch
            notify_and_call_entry_points(event)
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\gevent\events.py", line 105, in notify_and_call_entry_points
            subscriber(event)
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\geventmp\monkey.py", line 160, in _patch_mp
            _patch_module("_mp.3._mp_util", _patch_module=True, _package_prefix='geventmp.')
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\geventmp\monkey.py", line 121, in _patch_module
            gevent_module = import_module(_package_prefix + name)
          File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in import_module
            return _bootstrap._gcd_import(name[level:], package, level)
          File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
          File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
          File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
          File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
          File "<frozen importlib._bootstrap_external>", line 883, in exec_module
          File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
          File "Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\geventmp\_mp\3\_mp_util.py", line 16, in <module>
            from gevent.os import _watch_child
        ImportError: cannot import name '_watch_child' from 'gevent.os' (Z:\home\kirr\src\tools\go\pygo-win\1.wenv\lib\site-packages\gevent\os.py)
    
    That happens because geventmp does not support windows actually.
    
    -> Fix it by requiring geventmp to be present only on non-windows.
    
    Adjust related comment as https://github.com/karellen/geventmp/pull/2 has been merged long ago.
    f23a9ef5
setup.py 14.6 KB