posting
quadrismegistus 4 years ago
parent fbecdbecdc
commit d5dc3ff5d7

@ -50,7 +50,7 @@ echo '
path_repo="$path_komrade/code"
if ! command -v git &> /dev/null
then
if [-d "$path_repo"]
if [-d "$path_repo" ]
then
cd $path_repo
git pull
@ -76,21 +76,23 @@ echo '
'
# if ! command -v pyenv &> /dev/null
if [ ! -d "$HOME/.pyenv"]
if [ ! -d "$HOME/.pyenv" ]
then
echo "pyenv not installed. install?"
read -p "[Y/n] " pyenv_yn
if [ ! pyenv_yn=="n" ]; then
echo "Not install pyenv."
echo "Not installing pyenv."
else
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
echo "installing..."
curl https://pyenv.run | bash
echo "installing python 3.7.3..."
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
#eval "$(pyenv init -)"
pyenv install 3.7.3
@ -111,7 +113,15 @@ echo '
if command -v pyenv &> /dev/null
then
cd $path_repo
script/bootstrap
pyenv install --skip-existing
#VENV="${PWD##*/}.venv"
VENV="venv"
VENV=${VENV#-}
python -m venv $VENV
. $VENV/bin/activate
python -m pip install -U pip setuptools wheel
python -m pip install -r requirements.txt
else
cd $path_repo
python -m pip install virtualenv

@ -1,91 +0,0 @@
#!/usr/bin/env python3
URL_PYENV = 'https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer'
import os,sys,urllib,shutil
from urllib import request
import distutils
from distutils import dir_util
print('''
# # ## # # ### ## ### ####
# # # # #### # # # # # # #
## # # #### ### # # # # ###
# # # # # # # # #### # # #
# # ## # # # # # # ### ####
installing...
''')
PATH_HOME = os.path.expanduser('~')
PATH_KOMRADE = os.path.join(PATH_HOME,'komrade')
path_pyenv = os.path.join(PATH_HOME,'.pyenv')
path_repo = os.path.join(PATH_KOMRADE,'code')
def is_tool(name):
"""Check whether `name` is on PATH and marked as executable."""
from shutil import which
return which(name) is not None
def main():
# 1) get path
path_komrade = input('Path to save komrade to:\n['+PATH_KOMRADE+'] ').strip()
path_komrade = PATH_KOMRADE if not path_komrade else path_komrade
if not os.path.exists(path_komrade): os.makedirs(path_komrade)
os.chdir(path_komrade)
# 2) install pyenv?
if not os.path.exists(path_pyenv):
pyenv_yn = input('\npyenv is not installed. Install?\n[Y/n] ').strip().lower()
if pyenv_yn != 'n':
print('installing pyenv...')
os.system('curl https://pyenv.run | bash')
# # 3) download komrade
print('\ndownloading Komrade...')
if is_tool('git'):
if os.path.exists(path_repo):
os.chdir(path_repo)
os.system('git pull')
else:
os.chdir(path_komrade)
os.system('git clone https://github.com/Komrade/Komrade.git')
else:
os.chdir(path_komrade)
request.urlretrieve(
'https://github.com/Komrade/Komrade/archive/master.zip',
'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')
## 4) install komrade
os.chdir(path_repo)
os.environ['PYENV_ROOT']=path_pyenv
os.environ['PATH'] = os.path.join(path_pyenv,'bin') + os.environ['PATH']
# 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
''')
main()
Loading…
Cancel
Save