forked from MagicStack/uvloop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (91 loc) · 2.84 KB
/
Makefile
File metadata and controls
130 lines (91 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.PHONY: check-env compile clean all distclean test debug sdist clean-libuv
.PHONY: release sdist-libuv docs
PYTHON ?= python
all: compile
clean:
rm -fr dist/ doc/_build/
rm -fr uvloop/*.c uvloop/*.html uvloop/*.so build *.egg-info
rm -fr uvloop/handles/*.html uvloop/includes/*.html
find . -name '__pycache__' | xargs rm -rf
check-env:
$(PYTHON) -c "import cython; (cython.__version__ < '0.24') and exit(1)"
clean-libuv:
(cd vendor/libuv; git clean -dfX)
sdist-libuv: clean-libuv
/bin/sh vendor/libuv/autogen.sh
distclean: clean clean-libuv
compile: check-env clean
echo "DEF DEBUG = 0" > uvloop/__debug.pxi
$(PYTHON) -m cython -3 uvloop/loop.pyx; rm uvloop/__debug.*
@echo "$$UVLOOP_BUILD_PATCH_SCRIPT" | $(PYTHON)
$(PYTHON) setup.py build_ext --inplace
debug: check-env clean
echo "DEF DEBUG = 1" > uvloop/__debug.pxi
$(PYTHON) -m cython -3 -a -p uvloop/loop.pyx; rm uvloop/__debug.*
@echo "$$UVLOOP_BUILD_PATCH_SCRIPT" | $(PYTHON)
$(PYTHON) setup.py build_ext --inplace
docs: compile
cd docs && $(PYTHON) -m sphinx -a -b html . _build/html
test:
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest discover -s tests
$(PYTHON) -m unittest discover -s tests
sdist: clean compile test sdist-libuv
$(PYTHON) setup.py sdist
release: clean compile test sdist-libuv
$(PYTHON) setup.py sdist bdist_wheel upload
# 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)
# 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)
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)
with open('uvloop/loop.c', 'wt') as f:
f.write(src)
endef
export UVLOOP_BUILD_PATCH_SCRIPT