-
Notifications
You must be signed in to change notification settings - Fork 91
Expand file tree
/
Copy pathsetup.py
More file actions
65 lines (59 loc) · 1.83 KB
/
setup.py
File metadata and controls
65 lines (59 loc) · 1.83 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
"""
This file is used to specify Python extensions, which are used when using Cython.
Extensions are used only if the current runtime is CPython and only if there is not an
environment variable: `BLACKSHEEP_NO_EXTENSIONS=1`.
The logic is to support PyPy. See:
https://github.com/Neoteroi/BlackSheep/issues/539#issuecomment-2888631226
"""
import os
from setuptools import Extension, setup
import platform
COMPILE_ARGS = ["-O2"]
# Check for environment variable to skip extensions
skip_ext = os.environ.get("BLACKSHEEP_NO_EXTENSIONS", "0") == "1"
if platform.python_implementation() == "CPython" and not skip_ext:
ext_modules = [
Extension(
"blacksheep.url",
["blacksheep/url.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.exceptions",
["blacksheep/exceptions.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.headers",
["blacksheep/headers.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.cookies",
["blacksheep/cookies.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.contents",
["blacksheep/contents.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.messages",
["blacksheep/messages.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.scribe",
["blacksheep/scribe.c"],
extra_compile_args=COMPILE_ARGS,
),
Extension(
"blacksheep.baseapp",
["blacksheep/baseapp.c"],
extra_compile_args=COMPILE_ARGS,
),
]
else:
ext_modules = []
setup(ext_modules=ext_modules)