-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
113 lines (99 loc) · 3.04 KB
/
setup.py
File metadata and controls
113 lines (99 loc) · 3.04 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
from __future__ import division, print_function
from setuptools import setup
VERSION = '0.2.0'
import importlib
def raises_importerror(module):
try:
importlib.import_module(module)
return False
except ImportError:
return True
def check_if_installed(module, only_if=None, advice='', raise_=False):
"""
:param module: str, module to try to import or raise if not present
:param only_if: bool-callback, only raise if true.
:param advice: str, how to satisfy requirement
:param raise_: bool, raise or just print warning
"""
if raises_importerror(module):
if only_if and only_if():
# We're good, hopefully the requirement will be satisfied
# after installation
return
txt = "Missing extra dependency '{}'. {}".format(module, advice)
if raise_:
raise ImportError(txt)
else:
print('WARNING: %s' %txt)
else:
print("{} installed - OK!".format(module))
pre_dependencies = [
{
'module': 'PyQt4',
'advice': "Try e.g. 'apt-get install python-qt4'",
},
{
'module': 'PyQt5',
# If PyQt4 is importable, we don't raise
'only_if': lambda: raises_importerror('PyQt4'),
'advice': "Try e.g. 'pip3 install pyqt5'",
},
{
'module': 'matplotlib.backends.backend_qt4agg',
'only_if': lambda: raises_importerror('matplotlib') \
and raises_importerror('matplotlib.backends.backend_qt4agg'),
'advice': 'Try reinstalling matplotlib',
},
{
'module': 'matplotlib.backends.backend_qt5agg',
'only_if': lambda: raises_importerror('matplotlib') \
and raises_importerror('matplotlib.backends.backend_qt4agg'),
'advice': 'Try reinstalling matplotlib',
},
]
from setuptools.command.install import install
from setuptools.command.develop import develop
class PreInstallHook(install):
def run(self):
[check_if_installed(**dep_dict) for dep_dict in pre_dependencies]
install.run(self)
class PreDevelopHook(develop):
def run(self):
[check_if_installed(**dep_dict) for dep_dict in pre_dependencies]
develop.run(self)
setup(
name="inspector",
version=VERSION,
description='Tool for easy plotting of 1-dimensional data, '
'built on PyQt and matplotlib',
url='https://github.com/WattyAB/inspector',
author='Lennart Liberg, Watty AB',
license='Apache License 2.0',
packages=[
'inspector'
],
install_requires=[
'pandas>=0.17.0',
'numpy>=1.9.0',
'matplotlib>=1.4.2',
'mock',
],
extras_require={
'test': [
'nose',
],
'unpackers': [ # subject to change / move. Listed here in mean time.
'lz4',
'msgpack-python'
]
},
cmdclass={
'install': PreInstallHook,
'develop': PreDevelopHook,
},
entry_points={
'console_scripts': [
'inspector=inspector.main:main',
],
},
)