~gtg-user/gtg/documenters-credits

« back to all changes in this revision

Viewing changes to GTG/tools/import_liblarch.py

  • Committer: Lionel Dricot
  • Date: 2012-05-04 16:07:39 UTC
  • mfrom: (1176.1.6 performance)
  • Revision ID: ploum@ploum.net-20120504160739-olbs893e8cmg617d
Awesome performance work by Izidor

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
REQUIRED_LIBLARCH_API = "1.0"
26
26
GIT_CMD = "git clone https://github.com/liblarch/liblarch ../liblarch"
27
27
 
28
 
 
29
 
def import_liblarch():
 
28
def import_liblarch(use_local=False):
30
29
    """ Check if liblarch is installed and is compatible
31
30
 
32
 
    If not, provide information how to obtain the newest version """
 
31
    If not, provide information how to obtain the newest version.
 
32
    If use_local, prioritize local (development) liblarch in ../liblarch"""
33
33
 
34
34
    def check_liblarch():
35
35
        """ Import liblarch and find out which one is missing """
49
49
 
50
50
        return has_libraries, " and ".join(missing)
51
51
 
 
52
    if use_local:
 
53
        sys.path.insert(0, "../liblarch")
 
54
 
52
55
    has_libraries, missing = check_liblarch()
53
 
    if not has_libraries:
 
56
 
 
57
    if not use_local and not has_libraries:
54
58
        sys.path.append("../liblarch/")
55
59
        has_libraries, missing = check_liblarch()
56
60
 
83
87
    return True
84
88
 
85
89
if __name__ == "__main__":
86
 
    if import_liblarch():
 
90
    use_local = "-l" in sys.argv[1:] or "--local-liblarch" in sys.argv[1:]
 
91
 
 
92
    if import_liblarch(use_local):
87
93
        sys.exit(0)
88
94
    else:
89
95
        sys.exit(1)