|
|
@ -4,6 +4,10 @@ URL_PYENV = 'https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/
|
|
|
|
|
|
|
|
|
|
|
|
import os,sys,urllib,shutil
|
|
|
|
import os,sys,urllib,shutil
|
|
|
|
from urllib import request
|
|
|
|
from urllib import request
|
|
|
|
|
|
|
|
import distutils
|
|
|
|
|
|
|
|
from distutils import dir_util
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('''
|
|
|
|
print('''
|
|
|
|
# # ## # # ### ## ### ####
|
|
|
|
# # ## # # ### ## ### ####
|
|
|
@ -19,7 +23,7 @@ installing...
|
|
|
|
PATH_HOME = os.path.expanduser('~')
|
|
|
|
PATH_HOME = os.path.expanduser('~')
|
|
|
|
PATH_KOMRADE = os.path.join(PATH_HOME,'komrade')
|
|
|
|
PATH_KOMRADE = os.path.join(PATH_HOME,'komrade')
|
|
|
|
path_pyenv = os.path.join(PATH_HOME,'.pyenv')
|
|
|
|
path_pyenv = os.path.join(PATH_HOME,'.pyenv')
|
|
|
|
path_repo = os.path.join(PATH_KOMRADE,'Komrade')
|
|
|
|
path_repo = os.path.join(PATH_KOMRADE,'code')
|
|
|
|
def is_tool(name):
|
|
|
|
def is_tool(name):
|
|
|
|
"""Check whether `name` is on PATH and marked as executable."""
|
|
|
|
"""Check whether `name` is on PATH and marked as executable."""
|
|
|
|
from shutil import which
|
|
|
|
from shutil import which
|
|
|
@ -35,14 +39,15 @@ def main():
|
|
|
|
os.chdir(path_komrade)
|
|
|
|
os.chdir(path_komrade)
|
|
|
|
|
|
|
|
|
|
|
|
# 2) install pyenv?
|
|
|
|
# 2) install pyenv?
|
|
|
|
if not is_tool('pyenv') or not os.path.exists(path_pyenv):
|
|
|
|
if not os.path.exists(path_pyenv):
|
|
|
|
pyenv_yn = input('\npyenv is not installed. Install?\n[Y/n] ').strip().lower()
|
|
|
|
pyenv_yn = input('\npyenv is not installed. Install?\n[Y/n] ').strip().lower()
|
|
|
|
if pyenv_yn != 'n':
|
|
|
|
if pyenv_yn != 'n':
|
|
|
|
print('installing pyenv...')
|
|
|
|
print('installing pyenv...')
|
|
|
|
os.system('curl https://pyenv.run | bash')
|
|
|
|
os.system('curl https://pyenv.run | bash')
|
|
|
|
|
|
|
|
|
|
|
|
# # 3) download komrade
|
|
|
|
# # 3) download komrade
|
|
|
|
if is_tool('git2'):
|
|
|
|
print('\ndownloading Komrade...')
|
|
|
|
|
|
|
|
if is_tool('git'):
|
|
|
|
if os.path.exists(path_repo):
|
|
|
|
if os.path.exists(path_repo):
|
|
|
|
os.chdir(path_repo)
|
|
|
|
os.chdir(path_repo)
|
|
|
|
os.system('git pull')
|
|
|
|
os.system('git pull')
|
|
|
@ -51,16 +56,38 @@ def main():
|
|
|
|
os.system('git clone https://github.com/Komrade/Komrade.git')
|
|
|
|
os.system('git clone https://github.com/Komrade/Komrade.git')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
os.chdir(path_komrade)
|
|
|
|
os.chdir(path_komrade)
|
|
|
|
os.system('curl -o komrade-github.zip -LJO https://github.com/Komrade/Komrade/archive/master.zip')
|
|
|
|
request.urlretrieve(
|
|
|
|
os.system('unzip komrade-github.zip')
|
|
|
|
'https://github.com/Komrade/Komrade/archive/master.zip',
|
|
|
|
os.rename('Komrade-master','code')
|
|
|
|
'komrade-github.zip'
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
os.system('unzip -o komrade-github.zip')
|
|
|
|
|
|
|
|
distutils.dir_util.copy_tree("Komrade-master", "code")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shutil.rmtree('Komrade-master')
|
|
|
|
os.remove('komrade-github.zip')
|
|
|
|
os.remove('komrade-github.zip')
|
|
|
|
|
|
|
|
|
|
|
|
## 4) install komrade
|
|
|
|
## 4) install komrade
|
|
|
|
os.chdir(path_repo)
|
|
|
|
os.chdir(path_repo)
|
|
|
|
os.environ['PYENV_ROOT']=path_pyenv
|
|
|
|
os.environ['PYENV_ROOT']=path_pyenv
|
|
|
|
os.environ['PATH'] = os.path.join(path_pyenv,'bin') + os.environ['PATH']
|
|
|
|
os.environ['PATH'] = os.path.join(path_pyenv,'bin') + os.environ['PATH']
|
|
|
|
os.system('. script/bootstrap')
|
|
|
|
# os.system('. script/bootstrap')
|
|
|
|
|
|
|
|
os.system('''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export PYENV_ROOT="$HOME/.pyenv"
|
|
|
|
|
|
|
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo `which pyenv`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if command -v pyenv 1>/dev/null 2>&1; then
|
|
|
|
|
|
|
|
# eval "$(pyenv init -)"
|
|
|
|
|
|
|
|
#fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
. script/bootstrap
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
''')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|
|
|
|
main()
|