Commit 83ebd4d8 authored by Kirill Smelkov's avatar Kirill Smelkov

Fix build with python-dbg

I've tried to use gevent with debug build of CPython and got:

    $ virtualenv -p python-dbg 1.venv
    $ . 1.venv/bin/activate
    (1.venv) kirr@deco:~/src/tools/py/gevent$ pip install -v -e .
    ...
    (1.venv) kirr@deco:~/src/tools/py/gevent$ python
    Python 2.7.16 (default, Apr  6 2019, 01:42:57)
    [GCC 8.3.0] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import gevent
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/kirr/src/tools/py/gevent/src/gevent/__init__.py", line 87, in <module>
        from gevent._hub_local import get_hub
      File "/home/kirr/src/tools/py/gevent/src/gevent/_hub_local.py", line 101, in <module>
        import_c_accel(globals(), 'gevent.__hub_local')
      File "/home/kirr/src/tools/py/gevent/src/gevent/_util.py", line 105, in import_c_accel
        mod = importlib.import_module(cname)
      File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
        __import__(name)
    ImportError: /home/kirr/src/tools/py/gevent/src/gevent/__hub_local_d.so: undefined symbol: Py_InitModule4_64

Looking around I dound that CPython changes Py_InitModule4_64 symbol name under
debug build and that this change is used to catch usage of modules built for
normal interpreter with debug cpython build:

https://github.com/python/cpython/blob/v2.7.16-120-g46c2eff5adc/Include/modsupport.h#L105-L115
https://github.com/python/cpython/blob/v2.7.16-120-g46c2eff5adc/Include/object.h#L54-L57

Looking at C flags used to build __hub_local_d.o

    (1.venv) kirr@deco:~/src/tools/py/gevent$ touch src/gevent/_hub_local.c
    (1.venv) kirr@deco:~/src/tools/py/gevent$ python setup.py build_ext -i
    ...
    x86_64-linux-gnu-gcc -pthread -g -O0 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -g -O0 -fdebug-prefix-map=/build/python2.7-IbFBHb/python2.7-2.7.16=. -fstack-protector -Wformat -Werror=format-security -fPIC -I/home/kirr/tmp/trashme/1.venv/local/include/python2.7 -I/home/kirr/tmp/trashme/1.venv/include/site/python2.7 -Ideps -I/usr/include/python2.7_d -c src/gevent/_hub_local.c -o build/temp.linux-x86_64-2.7-pydebug/src/gevent/_hub_local.o

XXX
parent 9fbb9714
......@@ -4,7 +4,7 @@ from __future__ import print_function
import sys
import os
import os.path
import sysconfig
from distutils import sysconfig
# setuptools is *required* on Windows
# (https://bugs.python.org/issue23246) and for PyPy. No reason not to
......@@ -50,7 +50,7 @@ CORE = cythonize1(build_libev_extension())
# Get access to the greenlet header file.
# The sysconfig dir is not enough if we're in a virtualenv
# See https://github.com/pypa/pip/issues/4610
include_dirs = [sysconfig.get_path("include")]
include_dirs = [sysconfig.get_python_inc()]
venv_include_dir = os.path.join(sys.prefix, 'include', 'site',
'python' + sysconfig.get_python_version())
venv_include_dir = os.path.abspath(venv_include_dir)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment