forked from python/pythoncapi-compat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·66 lines (55 loc) · 1.64 KB
/
setup.py
File metadata and controls
executable file
·66 lines (55 loc) · 1.64 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
#!/usr/bin/env python3
import os.path
TEST_CPP = False
SRC_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), '..'))
# C compiler flags for GCC and clang
COMMON_FLAGS = [
# Treat warnings as error
'-Werror',
# Enable all warnings
'-Wall', '-Wextra',
# Extra warnings
'-Wconversion',
# /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef
# 'Py_hash_t' is a C11 feature
"-Wno-typedef-redefinition",
]
CFLAGS = COMMON_FLAGS + [
# Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a
# mixture of designated and non-designated initializers
'-std=c99',
]
CPPFLAGS = COMMON_FLAGS + [
# no C++ option yet
]
def main():
from distutils.core import setup, Extension
import sys
if len(sys.argv) >= 3 and sys.argv[2] == '--build-cppext':
global TEST_CPP
TEST_CPP = True
del sys.argv[2]
cflags = ['-I' + SRC_DIR]
cppflags = list(cflags)
# Windows uses MSVC compiler
if os.name != "nt":
cflags.extend(CFLAGS)
cppflags.extend(CPPFLAGS)
# C extension
c_ext = Extension(
'test_pythoncapi_compat_cext',
sources=['test_pythoncapi_compat_cext.c'],
extra_compile_args=cflags)
extensions = [c_ext]
if TEST_CPP:
# C++ extension
cpp_ext = Extension(
'test_pythoncapi_compat_cppext',
sources=['test_pythoncapi_compat_cppext.cpp'],
extra_compile_args=cppflags,
language='c++')
extensions.append(cpp_ext)
setup(name="test_pythoncapi_compat",
ext_modules=extensions)
if __name__ == "__main__":
main()