-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·77 lines (62 loc) · 1.7 KB
/
setup.py
File metadata and controls
executable file
·77 lines (62 loc) · 1.7 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
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env python
"""Initialize submodule and do install. Also adds clean command."""
from distutils.cmd import Command
from glob import glob
from shutil import rmtree
import os
import sys
from setuptools import setup, Extension
class Clean(Command):
"""Cleans build and dist directories."""
description = 'clean build and dist directories'
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
build_items = ['build', 'dist', 'i106.egg-info', '.cache', '.eggs',
'.pytest_cache']
build_items += glob('*.so')
for path in build_items:
if os.path.exists(path):
if os.path.isdir(path):
rmtree(path)
else:
os.remove(path)
# Install base library if missing
try:
if not os.listdir('src/libirig106'):
os.system('git submodule init && git submodule update')
except Exception as err:
print(err)
# Define flags based on platform.
if sys.platform == 'win32':
FLAGS = ['/Od', '/EHsc', '/MT']
LINK_FLAGS = []
else:
FLAGS = [
'-c',
'-std=c99',
'-fPIC',
'-Wall',
'-D_FILE_OFFSET_BITS=64',
'-D_LARGEFILE64_SOURCE',
'-ggdb',
]
LINK_FLAGS = ['-fPIC']
EXT = Extension(
'i106',
glob('src/*.c') + glob('src/libirig106/src/*.c'),
depends=glob('src/*.h') + glob('src/libirig106/src/*.h'),
extra_compile_args=FLAGS,
extra_link_args=LINK_FLAGS,
)
setup(
name='i106',
version='0.0.1',
ext_modules=[EXT],
cmdclass={'clean': Clean},
setup_requires=['pytest-runner'],
tests_require=['pytest'],
)