forked from intrepidcs/python_ics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
137 lines (112 loc) · 3.99 KB
/
setup.py
File metadata and controls
137 lines (112 loc) · 3.99 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env python3
from setuptools import setup, Extension
from distutils.command import build as build_module
import os
import platform
import sys
import unittest
import shutil
MAJOR_VERSION = 910
MINOR_VERSION = 999
POST_VERSION = None
if POST_VERSION:
VERSION_STRING = '%d.%d-%d' % (MAJOR_VERSION, MINOR_VERSION, POST_VERSION)
else:
VERSION_STRING = '%d.%d' % (MAJOR_VERSION, MINOR_VERSION)
def _run_tests():
directory = os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__))
loader = unittest.defaultTestLoader
runner = unittest.TextTestRunner()
suite = loader.discover(os.path.join(directory, 'test'))
runner.run(suite)
try:
from setuptools.command.test import test
class UnitTests(test):
def finalize_options(self):
test.finalize_options(self)
self.test_args = []
self.test_suite = True
def run_tests(self):
_run_tests()
except ImportError:
from distutils.core import Command
class UnitTests(Command):
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
_run_tests()
class build(build_module.build):
def run(self):
import extract_icsneo40_defines
import generate_icsneo40_structs
extract_icsneo40_defines.extract()
generate_icsneo40_structs.generate()
if 'DARWIN' in platform.system().upper():
import build_libicsneo
build_libicsneo.checkout()
build_libicsneo.build()
build_libicsneo.copy()
build_module.build.run(self)
home_path = os.path.expanduser('~')
# Grab all the source files
source_files = []
for root, dirs, files in os.walk('src'):
for file in files:
if file.endswith('.cpp') or file.endswith('.c'):
source_files.append(os.path.join(root, file))
# Set compiler flags here
if 'LINUX' in platform.system().upper() or "MSC" not in sys.version:
compile_args = [
'-fpermissive',
'-Wno-unused-variable',
'-Wno-unused-function',
'-Wno-write-strings'
]
else:
compile_args = []
# Check for clang stuff here, read the docs doesn't have this so use what is in the repo
if not os.getenv("READTHEDOCS"):
if not shutil.which('clang'):
raise RuntimeError("clang is required for building python_ics.")
if not shutil.which('clang-format'):
raise RuntimeError("clang-format is required for building python_ics.")
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
ics_extension = Extension(
'ics.ics',
define_macros=[('MAJOR_VERSION', MAJOR_VERSION),
('MINOR_VERSION', MINOR_VERSION),
('EXTERNAL_PROJECT', 1)],
include_dirs=['include', 'include/ics', 'include/ice'],
libraries=[],
library_dirs=['/usr/local/lib'],
sources=source_files, extra_compile_args=compile_args)
package_data = {}
if 'DARWIN' in platform.system().upper():
package_data['ics'] = ['*.dylib']
setup(name='python_ics',
version=VERSION_STRING,
description='Library for interfacing with Intrepid devices in Python',
long_description=read('README.md'),
license="MIT",
author='David Rebbe',
author_email='drebbe@intrepidcs.com',
maintainer='David Rebbe',
maintainer_email='drebbe@intrepidcs.com',
url='https://github.com/intrepidcs/python_ics/',
cmdclass={'build': build, 'test': UnitTests, },
download_url='https://github.com/intrepidcs/python_ics/releases',
packages=['ics', 'ics.structures'],
package_data=package_data,
include_package_data=True,
ext_modules=[ics_extension],
classifiers=[
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],)