forked from youknowone/pyre
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_externals.py
More file actions
59 lines (52 loc) · 1.89 KB
/
Copy pathget_externals.py
File metadata and controls
59 lines (52 loc) · 1.89 KB
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
'''Get external dependencies for building PyPy
they will end up in the platform.host().basepath, something like repo-root/external
'''
from __future__ import print_function
import argparse
import os
import shutil
import sys
import zipfile
from subprocess import Popen, PIPE, check_call
from rpython.translator.platform import host
def checkout_repo(dest='externals', org='pypy', branch='default', verbose=False):
url = 'https://github.com/{}/externals'.format(org)
if os.path.exists(dest):
if os.path.exists(os.path.join(dest, ".git")):
cmd = ['git', '-C', dest, 'pull', url]
else:
# remove a mercurial clone
shutil.rmtree(dest)
cmd = ['git','clone',url, dest]
else:
cmd = ['git','clone',url, dest]
check_call(cmd, verbose)
cmd = ['git','-C', dest, 'checkout',branch]
check_call(cmd)
def parse_args():
p = argparse.ArgumentParser()
p.add_argument('-v', '--verbose', action='store_true')
p.add_argument('-O', '--organization',
help='Organization owning the deps repos', default='pypy')
p.add_argument('-e', '--externals', default=host.externals,
help='directory in which to store dependencies',
)
p.add_argument('-b', '--branch', default=host.externals_branch,
help='branch to check out',
)
p.add_argument('-p', '--platform', default=None,
help='someday support cross-compilation, ignore for now',
)
return p.parse_args()
def main():
if sys.platform != "win32":
print("only needed on windows")
args = parse_args()
checkout_repo(
dest=args.externals,
org=args.organization,
branch=args.branch,
verbose=args.verbose,
)
if __name__ == '__main__':
main()