Commit c4b95fc4 authored by Jason Madden's avatar Jason Madden

isolate libev specific code to its own package.

parent 42e38b8f
...@@ -3,13 +3,13 @@ build/ ...@@ -3,13 +3,13 @@ build/
.runtimes .runtimes
.tox/ .tox/
*.so *.so
*.o
*.egg-info *.egg-info
gevent.*.[ch] gevent.*.[ch]
src/gevent/corecext.pyx src/gevent/libev/corecext.pyx
src/gevent/__pycache__ src/gevent/__pycache__
src/gevent/libev src/gevent/libev/_corecffi.c
src/gevent/_corecffi.c src/gevent/libev/_corecffi.o
src/gevent/_corecffi.o
Makefile.ext Makefile.ext
MANIFEST MANIFEST
*_flymake.py *_flymake.py
......
...@@ -12,12 +12,12 @@ export PATH:=$(BUILD_RUNTIMES)/snakepit:$(TOOLS):$(PATH) ...@@ -12,12 +12,12 @@ export PATH:=$(BUILD_RUNTIMES)/snakepit:$(TOOLS):$(PATH)
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
all: src/gevent/gevent.corecext.c src/gevent/gevent.ares.c src/gevent/gevent._semaphore.c all: src/gevent/libev/gevent.corecext.c src/gevent/gevent.ares.c src/gevent/gevent._semaphore.c
src/gevent/gevent.corecext.c: src/gevent/corecext.ppyx src/gevent/libev.pxd util/cythonpp.py src/gevent/libev/gevent.corecext.c: src/gevent/libev/corecext.ppyx src/gevent/libev/libev.pxd util/cythonpp.py
$(PYTHON) util/cythonpp.py -o gevent.corecext.c src/gevent/corecext.ppyx $(PYTHON) util/cythonpp.py -o gevent.corecext.c src/gevent/libev/corecext.ppyx
echo '#include "callbacks.c"' >> gevent.corecext.c echo '#include "callbacks.c"' >> gevent.corecext.c
mv gevent.corecext.* src/gevent/ mv gevent.corecext.* src/gevent/libev/
src/gevent/gevent.ares.c: src/gevent/ares.pyx src/gevent/*.pxd src/gevent/gevent.ares.c: src/gevent/ares.pyx src/gevent/*.pxd
$(CYTHON) -o gevent.ares.c src/gevent/ares.pyx $(CYTHON) -o gevent.ares.c src/gevent/ares.pyx
...@@ -35,13 +35,15 @@ src/gevent/gevent._semaphore.c: src/gevent/_semaphore.py src/gevent/_semaphore.p ...@@ -35,13 +35,15 @@ src/gevent/gevent._semaphore.c: src/gevent/_semaphore.py src/gevent/_semaphore.p
# rm src/gevent/_semaphore.py # rm src/gevent/_semaphore.py
clean: clean:
rm -f corecext.pyx src/gevent/corecext.pyx rm -f corecext.pyx src/gevent/libev/corecext.pyx
rm -f gevent.corecext.c gevent.corecext.h src/gevent/gevent.corecext.c src/gevent/gevent.corecext.h rm -f gevent.corecext.c gevent.corecext.h src/gevent/libev/gevent.corecext.c src/gevent/libev/gevent.corecext.h
rm -f gevent.ares.c gevent.ares.h src/gevent/gevent.ares.c src/gevent/gevent.ares.h rm -f gevent.ares.c gevent.ares.h src/gevent/gevent.ares.c src/gevent/gevent.ares.h
rm -f gevent._semaphore.c gevent._semaphore.h src/gevent/gevent._semaphore.c src/gevent/gevent._semaphore.h rm -f gevent._semaphore.c gevent._semaphore.h src/gevent/gevent._semaphore.c src/gevent/gevent._semaphore.h
rm -f src/gevent/*.so rm -f src/gevent/*.so src/gevent/libev/*.so
rm -rf src/gevent/__pycache__ rm -rf src/gevent/libev/*.o src/gevent/*.o
rm -rf src/gevent/*.pyc rm -rf src/gevent/__pycache__ src/greentest/__pycache__ src/gevent/libev/__pycache__
rm -rf src/gevent/*.pyc src/greentest/*.pyc src/gevent/libev/*.pyc
rm -rf src/greentest/htmlcov src/greentest/.coverage
doc: doc:
cd doc && PYTHONPATH=.. make html cd doc && PYTHONPATH=.. make html
......
IF "%PYTHON_EXE%" == "python" ( IF "%PYTHON_EXE%" == "python" (
%PYEXE% util\cythonpp.py -o gevent.corecext.c src\gevent\corecext.ppyx %PYEXE% util\cythonpp.py -o gevent.corecext.c src\gevent\libev\corecext.ppyx
type src\gevent\callbacks.c >> gevent.corecext.c type src\gevent\libev\callbacks.c >> gevent.corecext.c
move gevent.corecext.* src\gevent move gevent.corecext.* src\gevent\libev
) )
cython -o gevent.ares.c src\gevent\ares.pyx cython -o gevent.ares.c src\gevent\ares.pyx
move gevent.ares.* src\gevent move gevent.ares.* src\gevent
......
...@@ -29,6 +29,8 @@ Libraries ...@@ -29,6 +29,8 @@ Libraries
attempted at every import. This could lead to scattered "gevent" attempted at every import. This could lead to scattered "gevent"
directories and undependable results. directories and undependable results.
- Update Cython to 0.24. - Update Cython to 0.24.
- setuptools is now required at build time on all platforms.
Previously it was only required for Windows and PyPy.
Security Security
......
...@@ -10,6 +10,11 @@ from os.path import join, abspath, basename, dirname ...@@ -10,6 +10,11 @@ from os.path import join, abspath, basename, dirname
from subprocess import check_call from subprocess import check_call
from glob import glob from glob import glob
# setuptools is *required* on Windows
# (https://bugs.python.org/issue23246) and for PyPy. No reason not to
# use it everywhere.
from setuptools import Extension, setup
from setuptools import find_packages
PYPY = hasattr(sys, 'pypy_version_info') PYPY = hasattr(sys, 'pypy_version_info')
WIN = sys.platform.startswith('win') WIN = sys.platform.startswith('win')
...@@ -25,10 +30,6 @@ if PYPY and WIN and not CFFI_WIN_BUILD_ANYWAY: ...@@ -25,10 +30,6 @@ if PYPY and WIN and not CFFI_WIN_BUILD_ANYWAY:
raise Exception("Unable to install on PyPy/Windows") raise Exception("Unable to install on PyPy/Windows")
if WIN: if WIN:
# https://bugs.python.org/issue23246
# We must have setuptools on windows
__import__('setuptools')
# Make sure the env vars that make.cmd needs are set # Make sure the env vars that make.cmd needs are set
if not os.environ.get('PYTHON_EXE'): if not os.environ.get('PYTHON_EXE'):
os.environ['PYTHON_EXE'] = 'pypy' if PYPY else 'python' os.environ['PYTHON_EXE'] = 'pypy' if PYPY else 'python'
...@@ -42,14 +43,6 @@ import distutils ...@@ -42,14 +43,6 @@ import distutils
import distutils.sysconfig # to get CFLAGS to pass into c-ares configure script import distutils.sysconfig # to get CFLAGS to pass into c-ares configure script
try:
from setuptools import Extension, setup
except ImportError:
if PYPY:
# need setuptools for include_package_data to work
raise
from distutils.core import Extension, setup
from distutils.command.build_ext import build_ext from distutils.command.build_ext import build_ext
from distutils.command.sdist import sdist as _sdist from distutils.command.sdist import sdist as _sdist
from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError from distutils.errors import CCompilerError, DistutilsExecError, DistutilsPlatformError
...@@ -133,12 +126,12 @@ def expand(*lst): ...@@ -133,12 +126,12 @@ def expand(*lst):
return result return result
CORE = Extension(name='gevent.corecext', CORE = Extension(name='gevent.libev.corecext',
sources=['src/gevent/gevent.corecext.c'], sources=['src/gevent/libev/gevent.corecext.c'],
include_dirs=['deps/libev'] if LIBEV_EMBED else [], include_dirs=['deps/libev'] if LIBEV_EMBED else [],
libraries=libraries, libraries=libraries,
define_macros=define_macros, define_macros=define_macros,
depends=expand('src/gevent/callbacks.*', 'src/gevent/stathelper.c', 'src/gevent/libev*.h', 'deps/libev/*.*')) depends=expand('src/gevent/libev/callbacks.*', 'src/gevent/libev/stathelper.c', 'src/gevent/libev/libev*.h', 'deps/libev/*.*'))
# QQQ libev can also use -lm, however it seems to be added implicitly # QQQ libev can also use -lm, however it seems to be added implicitly
ARES = Extension(name='gevent.ares', ARES = Extension(name='gevent.ares',
...@@ -373,7 +366,7 @@ def read(name, *args): ...@@ -373,7 +366,7 @@ def read(name, *args):
except OSError: except OSError:
return '' return ''
cffi_modules = ['src/gevent/_corecffi_build.py:ffi'] cffi_modules = ['src/gevent/libev/_corecffi_build.py:ffi']
if PYPY: if PYPY:
install_requires = [] install_requires = []
...@@ -493,7 +486,7 @@ def run_setup(ext_modules, run_make): ...@@ -493,7 +486,7 @@ def run_setup(ext_modules, run_make):
maintainer_email='jason@nextthought.com', maintainer_email='jason@nextthought.com',
url='http://www.gevent.org/', url='http://www.gevent.org/',
package_dir={'': 'src'}, package_dir={'': 'src'},
packages=['gevent'], packages=find_packages('src'),
include_package_data=include_package_data, include_package_data=include_package_data,
ext_modules=ext_modules, ext_modules=ext_modules,
cmdclass=dict(build_ext=my_build_ext, sdist=sdist), cmdclass=dict(build_ext=my_build_ext, sdist=sdist),
......
...@@ -9,13 +9,13 @@ try: ...@@ -9,13 +9,13 @@ try:
if os.environ.get('GEVENT_CORE_CFFI_ONLY'): if os.environ.get('GEVENT_CORE_CFFI_ONLY'):
raise ImportError("Not attempting corecext") raise ImportError("Not attempting corecext")
from gevent import corecext as _core from gevent.libev import corecext as _core
except ImportError: except ImportError:
if os.environ.get('GEVENT_CORE_CEXT_ONLY'): if os.environ.get('GEVENT_CORE_CEXT_ONLY'):
raise raise
# CFFI/PyPy # CFFI/PyPy
from gevent import corecffi as _core from gevent.libev import corecffi as _core
copy_globals(_core, globals()) copy_globals(_core, globals())
......
...@@ -61,7 +61,7 @@ void vfd_free(int); ...@@ -61,7 +61,7 @@ void vfd_free(int);
include_dirs = [ include_dirs = [
thisdir, # libev_vfd.h thisdir, # libev_vfd.h
os.path.abspath(os.path.join(thisdir, '..', '..', 'deps', 'libev')), os.path.abspath(os.path.join(thisdir, '..', '..', '..', 'deps', 'libev')),
] ]
ffi.cdef(_cdef) ffi.cdef(_cdef)
ffi.set_source('gevent._corecffi', _source, include_dirs=include_dirs) ffi.set_source('gevent._corecffi', _source, include_dirs=include_dirs)
......
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
# cython: emit_code_comments=False # cython: emit_code_comments=False
cimport cython cimport cython
cimport libev cimport libev
# Note this is not the standard cython 'cpython' (which has a backwards compat alias of 'python')
# it's our custom def. If it's not on the include path, we get warned.
from python cimport * from python cimport *
# Work around lack of absolute_import in Cython # Work around lack of absolute_import in Cython
# Note for PY3: not doing so will leave reference to locals() on import # 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) # (reproducible under Python 3.3, not under Python 3.4; see test__refcount_core.py)
......
...@@ -914,7 +914,10 @@ def run_cython(filename, sourcehash, output_filename, banner, comment, cache=Non ...@@ -914,7 +914,10 @@ def run_cython(filename, sourcehash, output_filename, banner, comment, cache=Non
result = cache.get(sourcehash) if cache is not None else None result = cache.get(sourcehash) if cache is not None else None
# Use an array for the argument so that filename arguments are properly # Use an array for the argument so that filename arguments are properly
# quoted according to local convention # quoted according to local convention
command = [CYTHON, '-o', output_filename, '-I', os.path.join('src', 'gevent'), filename] command = [CYTHON, '-o', output_filename,
'-I', os.path.join('src', 'gevent', 'libev'),
'-I', os.path.join('src', 'gevent'), # python.pxd, shared with c-ares
filename]
if result is not None: if result is not None:
log('Reusing %s # %s', command, comment) log('Reusing %s # %s', command, comment)
return result return result
......
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