Commit 59f1e9c2 authored by Jason Madden's avatar Jason Madden

Rename C accelerator modules to avoid clashes.

Fixes #1480.
parent 66d56aba
Rename gevent's C accelerator extension modules using a prefix to
avoid clashing with other C extensions.
......@@ -48,81 +48,89 @@ from _setupares import ARES
CORE = cythonize1(build_libev_extension())
# Get access to the greenlet header file.
SEMAPHORE = Extension(name="gevent.__semaphore",
# Modules that we cythonize for performance.
# Be careful not to use simple names for these modules,
# as the non-static symbols cython generates do not include
# the module name. Thus an extension of 'gevent._queue'
# results in symbols like 'PyInit__queue', which is the same
# symbol used by the standard library _queue accelerator module.
# The name of the .pxd file must match the local name of the accelerator
# extension; however, sadly, the generated .c and .html files will
# still use the same name as the .py source.
SEMAPHORE = Extension(name="gevent._gevent_c_semaphore",
sources=["src/gevent/_semaphore.py"],
depends=['src/gevent/__semaphore.pxd'],
depends=['src/gevent/_gevent_c_semaphore.pxd'],
include_dirs=get_include_dirs())
LOCAL = Extension(name="gevent._local",
LOCAL = Extension(name="gevent._gevent_clocal",
sources=["src/gevent/local.py"],
depends=['src/gevent/_local.pxd'],
depends=['src/gevent/_gevent_clocal.pxd'],
include_dirs=get_include_dirs())
GREENLET = Extension(name="gevent._greenlet",
GREENLET = Extension(name="gevent._gevent_cgreenlet",
sources=[
"src/gevent/greenlet.py",
],
depends=[
'src/gevent/_greenlet.pxd',
'src/gevent/__ident.pxd',
'src/gevent/_gevent_cgreenlet.pxd',
'src/gevent/_gevent_c_ident.pxd',
'src/gevent/_ident.py'
],
include_dirs=get_include_dirs())
ABSTRACT_LINKABLE = Extension(name="gevent.__abstract_linkable",
ABSTRACT_LINKABLE = Extension(name="gevent._gevent_c_abstract_linkable",
sources=["src/gevent/_abstract_linkable.py"],
depends=['src/gevent/__abstract_linkable.pxd'],
depends=['src/gevent/_gevent_c_abstract_linkable.pxd'],
include_dirs=get_include_dirs())
IDENT = Extension(name="gevent.__ident",
IDENT = Extension(name="gevent._gevent_c_ident",
sources=["src/gevent/_ident.py"],
depends=['src/gevent/__ident.pxd'],
depends=['src/gevent/_gevent_c_ident.pxd'],
include_dirs=get_include_dirs())
IMAP = Extension(name="gevent.__imap",
IMAP = Extension(name="gevent._gevent_c_imap",
sources=["src/gevent/_imap.py"],
depends=['src/gevent/__imap.pxd'],
depends=['src/gevent/_gevent_c_imap.pxd'],
include_dirs=get_include_dirs())
EVENT = Extension(name="gevent._event",
EVENT = Extension(name="gevent._gevent_cevent",
sources=["src/gevent/event.py"],
depends=['src/gevent/_event.pxd'],
depends=['src/gevent/_gevent_cevent.pxd'],
include_dirs=get_include_dirs())
QUEUE = Extension(name="gevent._queue",
QUEUE = Extension(name="gevent._gevent_cqueue",
sources=["src/gevent/queue.py"],
depends=['src/gevent/_queue.pxd'],
depends=['src/gevent/_gevent_cqueue.pxd'],
include_dirs=get_include_dirs())
HUB_LOCAL = Extension(name="gevent.__hub_local",
HUB_LOCAL = Extension(name="gevent._gevent_c_hub_local",
sources=["src/gevent/_hub_local.py"],
depends=['src/gevent/__hub_local.pxd'],
depends=['src/gevent/_gevent_c_hub_local.pxd'],
include_dirs=get_include_dirs())
WAITER = Extension(name="gevent.__waiter",
WAITER = Extension(name="gevent._gevent_c_waiter",
sources=["src/gevent/_waiter.py"],
depends=['src/gevent/__waiter.pxd'],
depends=['src/gevent/_gevent_c_waiter.pxd'],
include_dirs=get_include_dirs())
HUB_PRIMITIVES = Extension(name="gevent.__hub_primitives",
HUB_PRIMITIVES = Extension(name="gevent._gevent_c_hub_primitives",
sources=["src/gevent/_hub_primitives.py"],
depends=['src/gevent/__hub_primitives.pxd'],
depends=['src/gevent/_gevent_c_hub_primitives.pxd'],
include_dirs=get_include_dirs())
GLT_PRIMITIVES = Extension(name="gevent.__greenlet_primitives",
GLT_PRIMITIVES = Extension(name="gevent._gevent_c_greenlet_primitives",
sources=["src/gevent/_greenlet_primitives.py"],
depends=['src/gevent/__greenlet_primitives.pxd'],
depends=['src/gevent/_gevent_c_greenlet_primitives.pxd'],
include_dirs=get_include_dirs())
TRACER = Extension(name="gevent.__tracer",
TRACER = Extension(name="gevent._gevent_c_tracer",
sources=["src/gevent/_tracer.py"],
depends=['src/gevent/__tracer.pxd'],
depends=['src/gevent/_gevent_c_tracer.pxd'],
include_dirs=get_include_dirs())
......
cimport cython
from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
cdef InvalidSwitchError
cdef Timeout
......
from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent._gevent_c_greenlet_primitives cimport SwitchOutGreenletWithLoop
cdef _threadlocal
......
cimport cython
from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
from gevent.__waiter cimport Waiter
from gevent.__waiter cimport MultipleWaiter
from gevent._gevent_c_waiter cimport Waiter
from gevent._gevent_c_waiter cimport MultipleWaiter
cdef InvalidSwitchError
cdef _waiter
......
cimport cython
from gevent._greenlet cimport Greenlet
from gevent.__semaphore cimport Semaphore
from gevent._queue cimport UnboundQueue
from gevent._gevent_cgreenlet cimport Greenlet
from gevent._gevent_c_semaphore cimport Semaphore
from gevent._gevent_cqueue cimport UnboundQueue
@cython.freelist(100)
@cython.internal
......
cimport cython
from gevent.__abstract_linkable cimport AbstractLinkable
from gevent._gevent_c_abstract_linkable cimport AbstractLinkable
cdef Timeout
......
cimport cython
from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
cdef sys
cdef ConcurrentObjectUseError
......
cimport cython
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent.__abstract_linkable cimport AbstractLinkable
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_abstract_linkable cimport AbstractLinkable
cdef _None
cdef reraise
......
# cython: auto_pickle=False
cimport cython
from gevent.__ident cimport IdentRegistry
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent.__waiter cimport Waiter
from gevent.__greenlet_primitives cimport SwitchOutGreenletWithLoop
from gevent._gevent_c_ident cimport IdentRegistry
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_waiter cimport Waiter
from gevent._gevent_c_greenlet_primitives cimport SwitchOutGreenletWithLoop
cdef bint _PYPY
cdef sys_getframe
......
# cython: auto_pickle=False
cimport cython
from gevent._greenlet cimport Greenlet
from gevent._gevent_cgreenlet cimport Greenlet
cdef bint _PYPY
cdef ref
......
cimport cython
from gevent.__waiter cimport Waiter
from gevent._event cimport Event
from gevent.__hub_local cimport get_hub_noargs as get_hub
from gevent._gevent_c_waiter cimport Waiter
from gevent._gevent_cevent cimport Event
from gevent._gevent_c_hub_local cimport get_hub_noargs as get_hub
cdef bint _greenlet_imported
cdef _heappush
......
......@@ -75,9 +75,19 @@ def copy_globals(source,
def import_c_accel(globs, cname):
"""
Import the C-accelerator for the __name__
Import the C-accelerator for the *cname*
and copy its globals.
The *cname* should be hardcoded to match the expected
C accelerator module.
Unless PURE_PYTHON is set (in the environment or automatically
on PyPy), then the C-accelerator is required.
"""
if not cname.startswith('gevent._gevent_c'):
# Old module code that hasn't been updated yet.
cname = cname.replace('gevent._',
'gevent._gevent_c')
name = globs.get('__name__')
......
......@@ -8,7 +8,7 @@
# that's a new feature that we don't need or want to allow in a gevent
# point release.
# cython: emit_code_comments=False, auto_pickle=False
# cython: emit_code_comments=False, auto_pickle=False, language_level=3str
# NOTE: We generally cannot use the Cython IF directive as documented
# at
......@@ -19,6 +19,9 @@
# C file for all platforms so that end users that don't use a binary
# wheel don't have to sit through cythonpp and other steps the Makefile does.
# See https://github.com/gevent/gevent/issues/1076
# We compile in 3str mode, which should mean we get absolute import
# by default.
from __future__ import absolute_import
cimport cython
cimport libev
......@@ -33,14 +36,11 @@ cdef extern from "Python.h":
int Py_ReprEnter(object)
void Py_ReprLeave(object)
# Work around lack of absolute_import in Cython
# Note for PY3: not doing so will leave reference to locals() on import
# (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py)
sys = __import__('sys', level=0)
os = __import__('os', level=0)
traceback = __import__('traceback', level=0)
signalmodule = __import__('signal', level=0)
getswitchinterval = __import__('gevent', level=0).getswitchinterval
import sys
import os
import traceback
import signal as signalmodule
from gevent import getswitchinterval
__all__ = ['get_version',
......
......@@ -71,7 +71,7 @@ class TestCExt(greentest.TestCase):
def test_c_extension(self):
self.assertEqual(IdentRegistry.__module__,
'gevent.__ident')
'gevent._gevent_c_ident')
......
......@@ -828,9 +828,9 @@ class TestCExt(greentest.TestCase): # pragma: no cover (we only do coverage on p
def test_c_extension(self):
self.assertEqual(greenlet.Greenlet.__module__,
'gevent._greenlet')
'gevent._gevent_cgreenlet')
self.assertEqual(greenlet.SpawnedLink.__module__,
'gevent._greenlet')
'gevent._gevent_cgreenlet')
@greentest.skipWithCExtensions("Needs pure python")
class TestPure(greentest.TestCase):
......
......@@ -414,7 +414,7 @@ class TestCExt(greentest.TestCase): # pragma: no cover
def test_c_extension(self):
self.assertEqual(local.__module__,
'gevent._local')
'gevent._gevent_clocal')
@greentest.skipWithCExtensions("Needs pure-python")
class TestPure(greentest.TestCase):
......
......@@ -91,7 +91,7 @@ class TestCExt(greentest.TestCase):
def test_c_extension(self):
self.assertEqual(Semaphore.__module__,
'gevent.__semaphore')
'gevent._gevent_c_semaphore')
class SwitchWithFixedHash(object):
......
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