forked from plotly/plotly.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
60 lines (53 loc) · 2.3 KB
/
__init__.py
File metadata and controls
60 lines (53 loc) · 2.3 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
import json
import warnings
from . version import __version__
import graph_objs
import plotly
import tools
import utils
from pkg_resources import resource_string
def _check_for_requirements():
s = resource_string('plotly', 'requirements.json').decode('utf-8')
reqs = json.loads(s)
for req, version in reqs['core'].items():
try:
exec "import {}".format(req)
except ImportError:
warnings.warn(
"{} is a core requirement, you'll have to install it "
"on your machine before being able to use the plotly "
"package.\n"
"Questions? feedback@plot.ly"
"".format(req))
else:
our_version = version.split('.')
exec "your_version = {}.__version__.split('.')".format(req)
for ours, yours in zip(our_version, your_version):
if int(ours) > int(yours):
warnings.warn(
"The core requirement, '{}', is on your "
"machine, but it may be out of date. If you run "
"into problems related to this package, "
"you should try updating to the version we test "
"with: '{}'. Your version: '{}'.\n"
"Questions? feedback@plot.ly"
"".format(req, version, ".".join(your_version)))
for req, version in reqs['optional'].items():
try:
exec "import {}".format(req)
except ImportError:
pass
else:
our_version = version.split('.')
exec "your_version = {}.__version__.split('.')".format(req)
for ours, yours in zip(our_version, your_version):
if int(ours) > int(yours):
warnings.warn(
"The optional requirement, '{}', is on your "
"machine, but it may be out of date. If you run "
"into problems related to this package, "
"you should try updating to the version we test "
"with: '{}'. Your version: '{}'.\n"
"Questions? feedback@plot.ly"
"".format(req, version, ".".join(your_version)))
_check_for_requirements()