comparison install.py @ 431:e0bb52007402

Add installation of homebrew stuff on Mac.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 01 Apr 2018 22:57:57 -0700
parents 350f7a55ff33
children 06a551d3fbb2
comparison
equal deleted inserted replaced
430:71a080d4d83c 431:e0bb52007402
10 10
11 11
12 dotfiles_dir = os.path.abspath(os.path.dirname(__file__)) 12 dotfiles_dir = os.path.abspath(os.path.dirname(__file__))
13 13
14 is_nix = True 14 is_nix = True
15 is_mac = False
15 is_windows = False 16 is_windows = False
16 if sys.platform == "win32": 17 if sys.platform == "win32":
17 is_nix = False 18 is_nix = False
18 is_windows = True 19 is_windows = True
20 if sys.platform == 'darwin':
21 is_mac = True
19 22
20 23
21 def _p(*paths, force_unix=False): 24 def _p(*paths, force_unix=False):
22 res = os.path.join(dotfiles_dir, *paths) 25 res = os.path.join(dotfiles_dir, *paths)
23 if force_unix: 26 if force_unix:
64 67
65 def only_on_nix(f): 68 def only_on_nix(f):
66 @functools.wraps(f) 69 @functools.wraps(f)
67 def decorator(*args, **kwargs): 70 def decorator(*args, **kwargs):
68 if is_nix: 71 if is_nix:
72 return f(*args, **kwargs)
73 return decorator
74
75
76 def only_on_mac(f):
77 @functools.wraps(f)
78 def decorator(*args, **kwargs):
79 if is_mac:
69 return f(*args, **kwargs) 80 return f(*args, **kwargs)
70 return decorator 81 return decorator
71 82
72 83
73 def only_on_win(f): 84 def only_on_win(f):
242 clone_git(url[len('[git]'):], full_path, force=force) 253 clone_git(url[len('[git]'):], full_path, force=force)
243 else: 254 else:
244 clone_hg(url, full_path, force=force) 255 clone_hg(url, full_path, force=force)
245 256
246 257
258 @only_on_mac
259 @run_priority(210)
260 def install_xcode():
261 if shutil.which('xcodebuild') is None:
262 print("Installing XCode")
263 subprocess.check_call(['xcode-select', '--install'])
264 subprocess.check_call(['sudo', 'xcodebuild', '-license', 'accept'])
265
266
267 @only_on_mac
268 @run_priority(209)
269 def install_homebrew():
270 if shutil.which('brew') is None:
271 print("Installing Homebrew and Homebrew Cask")
272 subprocess.check_call([
273 '/usr/bin/ruby', '-e',
274 "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"]) # NOQA
275 subprocess.check_call(['brew', 'tap', 'caskroom/fonts'])
276
277
278 @only_on_mac
279 @needs_config
280 @supports_forcing
281 @run_priority(208)
282 def install_mactools(cfg, force=False):
283 if not cfg.has_section('mactools'):
284 return
285
286 for name, _ in cfg.items('mactools'):
287 args = ['brew', 'install', name]
288 if force:
289 args.append('--force')
290 subprocess.check_call(args)
291
292
247 def main(): 293 def main():
248 print("dotfiles installer") 294 print("dotfiles installer")
249 print("python %s" % sys.version) 295 print("python %s" % sys.version)
250 print("on %s" % sys.platform) 296 print("on %s" % sys.platform)
251 print('') 297 print('')