forked from mabuchilab/Instrumental
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
64 lines (58 loc) · 2.18 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
import os
import os.path
from setuptools import setup, find_packages
from distutils.errors import DistutilsPlatformError
from distutils.ccompiler import new_compiler
description = "Library with high-level drivers for lab equipment"
classifiers = [
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Intended Audience :: Science/Research',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
]
# Load metadata from __about__.py
base_dir = os.path.dirname(__file__)
about = {}
with open(os.path.join(base_dir, 'instrumental', '__about__.py')) as f:
exec(f.read(), about)
# Check for cffi
try:
import cffi
new_compiler().compile(b'')
build_cffi_modules = True
except (ImportError, DistutilsPlatformError):
build_cffi_modules = False
# Find all cffi build scripts
keywords = {}
if build_cffi_modules:
keywords['setup_requires'] = ["cffi>=1.0.0"]
modules = []
for dirpath, dirnames, filenames in os.walk('instrumental'):
basename = os.path.basename(dirpath)
for fname in filenames:
if basename == '_cffi_build' and fname.startswith('build_'):
modules.append(os.path.join(dirpath, fname) + ':ffi')
keywords['cffi_modules'] = modules
if __name__ == '__main__':
setup(
name = about['__distname__'],
version = about['__version__'],
packages = find_packages(exclude=['*._cffi_build']),
package_data = {
'': ['*.h', '*.pyd'],
'instrumental': ['instrumental.conf.default']
},
author = about['__author__'],
author_email = about['__email__'],
description = description,
long_description = '\n'.join(open("README.rst").read().splitlines()[2:]),
url = about['__url__'],
license = about['__license__'],
classifiers = classifiers,
install_requires = ['numpy', 'scipy', 'pint>=0.6'],
**keywords
)
if not build_cffi_modules:
print("\nPython cffi is not installed, so CFFI modules were not built. If you would like "
"to use cffi-based drivers, first install cffi, then rebuild Instrumental")