2016-05-22 18:59:40 +00:00
|
|
|
.PHONY: check-env compile clean all distclean test debug sdist clean-libuv
|
2016-05-08 04:30:27 +00:00
|
|
|
.PHONY: release sdist-libuv docs
|
2015-11-03 23:49:23 +00:00
|
|
|
|
|
|
|
|
2016-07-05 18:38:55 +00:00
|
|
|
PYTHON ?= python
|
|
|
|
|
|
|
|
|
2016-05-22 18:59:40 +00:00
|
|
|
all: compile
|
2015-11-01 17:00:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
clean:
|
2016-05-08 04:30:27 +00:00
|
|
|
rm -fr dist/ doc/_build/
|
2016-04-14 16:53:08 +00:00
|
|
|
rm -fr uvloop/*.c uvloop/*.html uvloop/*.so build *.egg-info
|
|
|
|
rm -fr uvloop/handles/*.html uvloop/includes/*.html
|
2015-11-03 17:42:21 +00:00
|
|
|
find . -name '__pycache__' | xargs rm -rf
|
2015-11-01 17:00:43 +00:00
|
|
|
|
|
|
|
|
2016-05-22 18:59:40 +00:00
|
|
|
check-env:
|
2016-07-05 18:38:55 +00:00
|
|
|
$(PYTHON) -c "import cython; (cython.__version__ < '0.24') and exit(1)"
|
2016-05-22 18:59:40 +00:00
|
|
|
|
2016-05-23 02:28:09 +00:00
|
|
|
|
2016-04-12 14:28:39 +00:00
|
|
|
clean-libuv:
|
2016-07-29 16:07:16 +00:00
|
|
|
(cd vendor/libuv; git clean -dfX)
|
2015-11-03 23:49:23 +00:00
|
|
|
|
|
|
|
|
2016-05-05 17:06:10 +00:00
|
|
|
sdist-libuv: clean-libuv
|
|
|
|
/bin/sh vendor/libuv/autogen.sh
|
|
|
|
|
|
|
|
|
2016-04-12 14:28:39 +00:00
|
|
|
distclean: clean clean-libuv
|
|
|
|
|
|
|
|
|
2016-05-22 18:59:40 +00:00
|
|
|
compile: check-env clean
|
2015-11-26 01:35:36 +00:00
|
|
|
echo "DEF DEBUG = 0" > uvloop/__debug.pxi
|
2016-07-29 15:55:40 +00:00
|
|
|
$(PYTHON) -m cython -3 uvloop/loop.pyx; rm uvloop/__debug.*
|
2016-07-05 18:38:55 +00:00
|
|
|
@echo "$$UVLOOP_BUILD_PATCH_SCRIPT" | $(PYTHON)
|
|
|
|
$(PYTHON) setup.py build_ext --inplace
|
2015-11-26 01:35:36 +00:00
|
|
|
|
|
|
|
|
2016-05-22 18:59:40 +00:00
|
|
|
debug: check-env clean
|
2015-11-26 01:35:36 +00:00
|
|
|
echo "DEF DEBUG = 1" > uvloop/__debug.pxi
|
2016-07-29 15:55:40 +00:00
|
|
|
$(PYTHON) -m cython -3 -a -p uvloop/loop.pyx; rm uvloop/__debug.*
|
2016-07-05 18:38:55 +00:00
|
|
|
@echo "$$UVLOOP_BUILD_PATCH_SCRIPT" | $(PYTHON)
|
|
|
|
$(PYTHON) setup.py build_ext --inplace
|
2015-11-10 22:41:22 +00:00
|
|
|
|
|
|
|
|
2016-05-08 04:30:27 +00:00
|
|
|
docs: compile
|
2016-07-05 18:38:55 +00:00
|
|
|
cd docs && $(PYTHON) -m sphinx -a -b html . _build/html
|
2016-05-08 04:30:27 +00:00
|
|
|
|
|
|
|
|
2015-11-10 22:41:22 +00:00
|
|
|
test:
|
2016-07-29 15:56:43 +00:00
|
|
|
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -s tests
|
2016-07-05 18:38:55 +00:00
|
|
|
$(PYTHON) -m unittest discover -s tests
|
2016-04-12 13:52:32 +00:00
|
|
|
|
|
|
|
|
2016-05-05 17:06:10 +00:00
|
|
|
sdist: clean compile test sdist-libuv
|
2016-07-05 18:38:55 +00:00
|
|
|
$(PYTHON) setup.py sdist
|
2016-04-12 14:28:39 +00:00
|
|
|
|
|
|
|
|
2016-05-09 03:07:15 +00:00
|
|
|
release: clean compile test sdist-libuv
|
2016-07-05 18:38:55 +00:00
|
|
|
$(PYTHON) setup.py sdist bdist_wheel upload
|
2016-05-14 17:41:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Script to patch Cython 'async def' coroutines to have a 'tp_iter' slot,
|
|
|
|
# which makes them compatible with 'yield from' without the
|
|
|
|
# `asyncio.coroutine` decorator.
|
|
|
|
define UVLOOP_BUILD_PATCH_SCRIPT
|
|
|
|
import re
|
|
|
|
|
|
|
|
with open('uvloop/loop.c', 'rt') as f:
|
|
|
|
src = f.read()
|
|
|
|
|
|
|
|
src = re.sub(
|
|
|
|
r'''
|
|
|
|
\s* offsetof\(__pyx_CoroutineObject,\s*gi_weakreflist\),
|
|
|
|
\s* 0,
|
|
|
|
\s* 0,
|
|
|
|
\s* __pyx_Coroutine_methods,
|
|
|
|
\s* __pyx_Coroutine_memberlist,
|
|
|
|
\s* __pyx_Coroutine_getsets,
|
|
|
|
''',
|
|
|
|
|
|
|
|
r'''
|
|
|
|
offsetof(__pyx_CoroutineObject, gi_weakreflist),
|
|
|
|
__Pyx_Coroutine_await, /* tp_iter */
|
|
|
|
0,
|
|
|
|
__pyx_Coroutine_methods,
|
|
|
|
__pyx_Coroutine_memberlist,
|
|
|
|
__pyx_Coroutine_getsets,
|
|
|
|
''',
|
|
|
|
|
|
|
|
src, flags=re.X)
|
|
|
|
|
2016-05-14 21:40:00 +00:00
|
|
|
# Fix a segfault in Cython.
|
|
|
|
src = re.sub(
|
|
|
|
r'''
|
|
|
|
\s* __Pyx_Coroutine_get_qualname\(__pyx_CoroutineObject\s+\*self\)
|
|
|
|
\s* {
|
|
|
|
\s* Py_INCREF\(self->gi_qualname\);
|
|
|
|
''',
|
|
|
|
|
|
|
|
r'''
|
|
|
|
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self)
|
|
|
|
{
|
|
|
|
if (self->gi_qualname == NULL) { return __pyx_empty_unicode; }
|
|
|
|
Py_INCREF(self->gi_qualname);
|
|
|
|
''',
|
|
|
|
|
|
|
|
src, flags=re.X)
|
|
|
|
|
2016-05-14 23:30:48 +00:00
|
|
|
src = re.sub(
|
|
|
|
r'''
|
|
|
|
\s* __Pyx_Coroutine_get_name\(__pyx_CoroutineObject\s+\*self\)
|
|
|
|
\s* {
|
|
|
|
\s* Py_INCREF\(self->gi_name\);
|
|
|
|
''',
|
|
|
|
|
|
|
|
r'''
|
|
|
|
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self)
|
|
|
|
{
|
|
|
|
if (self->gi_name == NULL) { return __pyx_empty_unicode; }
|
|
|
|
Py_INCREF(self->gi_name);
|
|
|
|
''',
|
|
|
|
|
|
|
|
src, flags=re.X)
|
|
|
|
|
2016-05-14 17:41:24 +00:00
|
|
|
with open('uvloop/loop.c', 'wt') as f:
|
|
|
|
f.write(src)
|
|
|
|
endef
|
|
|
|
export UVLOOP_BUILD_PATCH_SCRIPT
|