-
Notifications
You must be signed in to change notification settings - Fork 57
/
setup.py
53 lines (43 loc) · 1.32 KB
/
setup.py
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
import os
import platform
import setuptools
system = platform.uname().system
CFLAGS = ['-O2']
if system == 'AIX':
CFLAGS.extend(['-qlanglvl=stdc99', '-qchars'])
elif system == 'SUNOS':
CFLAGS.extend(['-xc99']) # -xchar=s is the default
elif system != 'Windows':
CFLAGS.extend(['-std=c99', '-fsigned-char', '-Wall',
'-Wsign-compare', '-Wconversion'])
with open(os.path.join(
os.path.dirname(__file__), 'immutables', '_version.py')) as f:
for line in f:
if line.startswith('__version__ ='):
_, _, version = line.partition('=')
VERSION = version.strip(" \n'\"")
break
else:
raise RuntimeError(
'unable to read the version from immutables/_version.py')
if platform.python_implementation() == 'CPython':
if os.environ.get("DEBUG_IMMUTABLES") == '1':
define_macros = []
undef_macros = ['NDEBUG']
else:
define_macros = [('NDEBUG', '1')]
undef_macros = []
ext_modules = [
setuptools.Extension(
"immutables._map",
["immutables/_map.c"],
extra_compile_args=CFLAGS,
define_macros=define_macros,
undef_macros=undef_macros)
]
else:
ext_modules = []
setuptools.setup(
version=VERSION,
ext_modules=ext_modules,
)