5
5
from distutils .command .build_ext import build_ext
6
6
from typing import Any
7
7
8
+ try :
9
+ from setuptools import Extension
10
+ except ImportError :
11
+ from distutils .core import Extension
12
+
8
13
_LOGGER = logging .getLogger (__name__ )
9
14
15
+ TO_CYTHONIZE = [
16
+ "src/zeroconf/_dns.py" ,
17
+ "src/zeroconf/_cache.py" ,
18
+ "src/zeroconf/_history.py" ,
19
+ "src/zeroconf/_record_update.py" ,
20
+ "src/zeroconf/_listener.py" ,
21
+ "src/zeroconf/_protocol/incoming.py" ,
22
+ "src/zeroconf/_protocol/outgoing.py" ,
23
+ "src/zeroconf/_handlers/answers.py" ,
24
+ "src/zeroconf/_handlers/record_manager.py" ,
25
+ "src/zeroconf/_handlers/multicast_outgoing_queue.py" ,
26
+ "src/zeroconf/_handlers/query_handler.py" ,
27
+ "src/zeroconf/_services/__init__.py" ,
28
+ "src/zeroconf/_services/browser.py" ,
29
+ "src/zeroconf/_services/info.py" ,
30
+ "src/zeroconf/_services/registry.py" ,
31
+ "src/zeroconf/_updates.py" ,
32
+ "src/zeroconf/_utils/ipaddress.py" ,
33
+ "src/zeroconf/_utils/time.py" ,
34
+ ]
35
+
36
+ EXTENSIONS = [
37
+ Extension (
38
+ ext .removeprefix ("src/" ).removesuffix (".py" ).replace ("/" , "." ),
39
+ [ext ],
40
+ language = "c" ,
41
+ extra_compile_args = ["-O3" , "-g0" ],
42
+ )
43
+ for ext in TO_CYTHONIZE
44
+ ]
45
+
10
46
11
47
class BuildExt (build_ext ):
12
48
def build_extensions (self ) -> None :
@@ -25,26 +61,7 @@ def build(setup_kwargs: Any) -> None:
25
61
setup_kwargs .update (
26
62
{
27
63
"ext_modules" : cythonize (
28
- [
29
- "src/zeroconf/_dns.py" ,
30
- "src/zeroconf/_cache.py" ,
31
- "src/zeroconf/_history.py" ,
32
- "src/zeroconf/_record_update.py" ,
33
- "src/zeroconf/_listener.py" ,
34
- "src/zeroconf/_protocol/incoming.py" ,
35
- "src/zeroconf/_protocol/outgoing.py" ,
36
- "src/zeroconf/_handlers/answers.py" ,
37
- "src/zeroconf/_handlers/record_manager.py" ,
38
- "src/zeroconf/_handlers/multicast_outgoing_queue.py" ,
39
- "src/zeroconf/_handlers/query_handler.py" ,
40
- "src/zeroconf/_services/__init__.py" ,
41
- "src/zeroconf/_services/browser.py" ,
42
- "src/zeroconf/_services/info.py" ,
43
- "src/zeroconf/_services/registry.py" ,
44
- "src/zeroconf/_updates.py" ,
45
- "src/zeroconf/_utils/ipaddress.py" ,
46
- "src/zeroconf/_utils/time.py" ,
47
- ],
64
+ EXTENSIONS ,
48
65
compiler_directives = {"language_level" : "3" }, # Python 3
49
66
),
50
67
"cmdclass" : {"build_ext" : BuildExt },
0 commit comments