-
Notifications
You must be signed in to change notification settings - Fork 1
/
requirements.py
66 lines (54 loc) · 1.53 KB
/
requirements.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
65
#! /usr/bin/env python
# Preference the local directory first...
import sys
sys.path.insert(0, '.')
import os.path
# If we are working from git, initialise the submodules
modules = [("libtpproto-py", "tp.netlib"), ("libtpclient-py", "tp.client")] #, ("schemepy", "schemepy")]
if os.path.exists(".git"):
for dir, name in modules:
if os.path.exists(dir) and not os.path.exists(os.path.join(dir, ".git")):
os.system("git submodule init")
os.system("git submodule update")
for dir, name in modules:
if os.path.exists(dir):
sys.path.insert(0, dir)
# Try and figure out what type of system this computer is running.
import os
result = os.system('apt-get --version > /dev/null 2>&1')
if result == 0:
system = "debian-based"
else:
system = "unknown"
# Check for our dependencies.
notfound = []
for dir, name in modules:
try:
exec("import %s as module" % name)
#print "%s version" % dir, module.__version__
#print " (installed at %s)" % module.__installpath__
try:
exec("from %s.version import version_git" % name)
#print " (git %s)" % version_git
except ImportError:
pass
except (ImportError, KeyError, AttributeError), e:
print e
notfound.append(dir)
print
try:
import logilab.constraint
except ImportError, e:
print e
if system == "debian-based":
notfound.append("python-constraint")
else:
notfound.append("logilab.constraint")
if len(notfound) > 0:
print "The following requirements where not met:"
for module in notfound:
print ' ', module
print
if len(notfound) > 0:
import sys
sys.exit(1)