-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_ruby_packages
executable file
·46 lines (34 loc) · 1.14 KB
/
install_ruby_packages
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
#!/usr/bin/env python3
#
# Install Ruby modules in the install_ruby_packages.gemfile Gemfile.
import sys
import subprocess
import shutil
def emulate_run(args, env=None):
p = subprocess.Popen(args, env=env)
if p.wait() == 0:
return True
return False
def emulate_backtick(args):
try:
output = subprocess.check_output(args, universal_newlines=True).rstrip('\n')
except Exception:
output = ''
return output
ruby = shutil.which('ruby')
gem = shutil.which('gem')
if not gem and sys.platform.startswith('win32'):
gem = shutil.which('gem.bat')
if not gem and sys.platform.startswith('win32'):
gem = shutil.which('gem.cmd')
if not gem and sys.platform.startswith('win32'):
gem = 'gem.cmd'
if __name__ == '__main__':
if not ruby:
print('error: Ruby not installed, not installing Ruby packages.')
sys.exit(1)
if not gem:
print('error: gem is not available, skipping Ruby module installation')
sys.exit(1)
error = not emulate_run([gem, 'install', '--user-install', '--update-sources', '--file', 'install_ruby_packages.gemfile'])
sys.exit(1 if error else 0)