1
+ import json
2
+ import warnings
1
3
from . version import __version__
2
4
import graph_objs
3
5
import plotly
4
6
import tools
5
- import utils
7
+ import utils
8
+
9
+ from pkg_resources import resource_string
10
+
11
+
12
+ def _check_for_requirements ():
13
+ s = resource_string ('plotly' , 'requirements.json' ).decode ('utf-8' )
14
+
15
+ reqs = json .loads (s )
16
+
17
+ for req , version in reqs ['core' ].items ():
18
+ try :
19
+ exec "import {}" .format (req )
20
+ except ImportError :
21
+ warnings .warn (
22
+ "{} is a core requirement, you'll have to install it "
23
+ "on your machine before being able to use the plotly "
24
+ "package." .format (req ))
25
+ else :
26
+ our_version = version .split ('.' )
27
+ exec "your_version = {}.__version__.split('.')" .format (req )
28
+ for ours , yours in zip (our_version , your_version ):
29
+ if int (ours ) > int (yours ):
30
+ warnings .warn (
31
+ "The core requirement, '{}', is on your "
32
+ "machine, but it may be out of date. If you run "
33
+ "into problems related to this package, "
34
+ "you should try updating to the version we test "
35
+ "with: '{}'. Your version: '{}'."
36
+ "" .format (req , version , "." .join (your_version )))
37
+
38
+ for req , version in reqs ['optional' ].items ():
39
+ try :
40
+ exec "import {}" .format (req )
41
+ except ImportError :
42
+ pass
43
+ else :
44
+ our_version = version .split ('.' )
45
+ exec "your_version = {}.__version__.split('.')" .format (req )
46
+ for ours , yours in zip (our_version , your_version ):
47
+ if int (ours ) > int (yours ):
48
+ warnings .warn (
49
+ "The optional requirement, '{}', is on your "
50
+ "machine, but it may be out of date. If you run "
51
+ "into problems related to this package, "
52
+ "you should try updating to the version we test "
53
+ "with: '{}'. Your version: '{}'."
54
+ "" .format (req , version , "." .join (your_version )))
55
+
56
+ _check_for_requirements ()
0 commit comments