-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.py
executable file
·68 lines (57 loc) · 1.61 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
import os
import sys
from fnmatch import fnmatch
from numpy import get_include as numpy_includes
from setuptools import setup, Extension
import sysconfig
def c_sources(parent):
sources = []
for root, _, files in os.walk(parent):
for f in files:
fn = os.path.join(root, f)
if fnmatch(fn, '*.c'):
sources.append(fn)
return sources
def c_includes(parent, depth=1):
includes = [parent]
for root, dirs, _ in os.walk(parent):
for d in dirs:
dn = os.path.join(root, d)
if len(dn.split(os.sep)) - 1 > depth:
continue
includes.append(dn)
return includes
SOURCES = c_sources('src')
INCLUDES = c_includes('include') + c_includes('src') + [numpy_includes()]
cfg = {
'libraries': [],
'define_macros': [],
'extra_compile_args': [],
}
if sys.platform == 'win32':
cfg['define_macros'].append(('__STDC__', 1))
cfg['define_macros'].append(('_CRT_SECURE_NO_WARNINGS', None))
else:
cfg['define_macros'].append(('NDEBUG', None))
cfg['libraries'].append('m')
cfg['extra_compile_args'] += [
'-Wall',
'-Wextra',
'-Wpedantic',
'-Wno-unused-parameter',
'-Wincompatible-pointer-types'
]
# importing these extension modules is tested in `.github/workflows/build.yml`;
# when adding new modules here, make sure to add them to the `test_command` entry there
ext_modules = [
Extension(
'stsci.stimage._stimage',
sources=SOURCES,
include_dirs=INCLUDES,
**cfg,
),
]
setup(
ext_modules=ext_modules,
)