Install development packages in the user directory
[litex.git] / litex_setup.py
1 #!/usr/bin/env python3
2
3 import os
4 import sys
5 from collections import OrderedDict
6
7
8 current_path = os.path.dirname(os.path.realpath(__file__))
9
10 # name, (url, recursive clone, develop)
11 repos = [
12 ("migen", ("http://github.com/m-labs/", True, True)),
13 ("litex", ("http://github.com/enjoy-digital/", True, True)),
14 ("liteeth", ("http://github.com/enjoy-digital/", False, True)),
15 ("liteusb", ("http://github.com/enjoy-digital/", False, True)),
16 ("litedram", ("http://github.com/enjoy-digital/", False, True)),
17 ("litepcie", ("http://github.com/enjoy-digital/", False, True)),
18 ("litesata", ("http://github.com/enjoy-digital/", False, True)),
19 ("litesdcard", ("http://github.com/enjoy-digital/", False, True)),
20 ("liteiclink", ("http://github.com/enjoy-digital/", False, True)),
21 ("litevideo", ("http://github.com/enjoy-digital/", False, True)),
22 ("litescope", ("http://github.com/enjoy-digital/", False, True)),
23 ]
24 repos = OrderedDict(repos)
25
26 if len(sys.argv) < 2:
27 print("Available commands:")
28 print("- init")
29 print("- install")
30 print("- update")
31 exit()
32
33 if "init" in sys.argv[1:]:
34 for name in repos.keys():
35 url, need_recursive, need_develop = repos[name]
36 # clone repo (recursive if needed)
37 print("[cloning " + name + "]...")
38 full_url = url + name
39 opts = "--recursive" if need_recursive else ""
40 os.system("git clone " + full_url + " " + opts)
41
42 if "install" in sys.argv[1:]:
43 for name in repos.keys():
44 url, need_recursive, need_develop = repos[name]
45 # develop if needed
46 print("[installing " + name + "]...")
47 if need_develop:
48 os.chdir(os.path.join(current_path, name))
49 os.system("python3 setup.py develop --user")
50
51 if "update" in sys.argv[1:]:
52 for name in repos.keys():
53 # update
54 print("[updating " + name + "]...")
55 os.chdir(os.path.join(current_path, name))
56 os.system("git pull")