MCPcopy Index your code
hub / github.com/kivy/python-for-android / check_python_dependencies

Function check_python_dependencies

pythonforandroid/checkdependencies.py:12–64  ·  view source on GitHub ↗

Check if the Python requirements are installed. This must appears before other imports because otherwise they're imported elsewhere. Using the ok check instead of failing immediately so that all errors are printed at once.

()

Source from the content-addressed store, hash-verified

10
11
12def check_python_dependencies():
13 """
14 Check if the Python requirements are installed. This must appears
15 before other imports because otherwise they're imported elsewhere.
16
17 Using the ok check instead of failing immediately so that all
18 errors are printed at once.
19 """
20
21 ok = True
22
23 modules = [("colorama", "0.3.3"), "appdirs", ("sh", "1.10"), "jinja2"]
24
25 for module in modules:
26 if isinstance(module, tuple):
27 module, version = module
28 else:
29 version = None
30
31 try:
32 import_module(module)
33 except ImportError:
34 if version is None:
35 print(
36 "ERROR: The {} Python module could not be found, please "
37 "install it.".format(module)
38 )
39 ok = False
40 else:
41 print(
42 "ERROR: The {} Python module could not be found, "
43 "please install version {} or higher".format(
44 module, version
45 )
46 )
47 ok = False
48 else:
49 if version is None:
50 continue
51 try:
52 cur_ver = sys.modules[module].__version__
53 except AttributeError: # this is sometimes not available
54 continue
55 if Version(cur_ver) < Version(version):
56 print(
57 "ERROR: {} version is {}, but python-for-android needs "
58 "at least {}.".format(module, cur_ver, version)
59 )
60 ok = False
61
62 if not ok:
63 print("python-for-android is exiting due to the errors logged above")
64 exit(1)
65
66
67def check():

Callers 1

checkFunction · 0.85

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected