-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
executable file
·113 lines (93 loc) · 3.85 KB
/
install.sh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# if ! type pipenv > /dev/null 2>&1
# then
# # Install Pipenv
# echo -e "\033[46mInstalling pipenv\033[0m"
# curl -sSL https://raw.githubusercontent.com/pypa/pipenv/master/get-pipenv.py | python3 -
# if type pipenv > /dev/null 2>&1
# then
# echo -e "\033[46;1mPipenv successfully installed\033[0m"
# else
# echo -e "\033[41;1mInstallation failed\033[0m"
# exit 1
# fi
# fi
# # Change-directory to the current package
# # *In case this script is executed from other directory, Pipfile won't be found
# package_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
# cd ${package_dir}
# # Try pipenv sync command
# if pipenv sync --system --dev
# then
# echo -e "\033[46;1m===========================================\033[0m"
# echo -e "\033[46;1m= Successfully installed the dependencies =\033[0m"
# echo -e "\033[46;1m===========================================\033[0m"
# else
# echo -e "\033[46;1m======================================\033[0m"
# echo -e "\033[46;1m= Installation failed, trying update =\033[0m"
# echo -e "\033[46;1m======================================\033[0m"
# # If pipenv sync failed, run pipenv update (= pipenv lock && pipenv sync)
# if pipenv lock && pipenv sync --system --dev
# then
# echo -e "\033[46;1m=========================================\033[0m"
# echo -e "\033[46;1m= Successfully updated the dependencies =\033[0m"
# echo -e "\033[46;1m=========================================\033[0m"
# else
# echo -e "\033[41;1m=========================================\033[0m"
# echo -e "\033[41;1m= poetry failed to resolve dependencies =\033[0m"
# echo -e "\033[41;1m=========================================\033[0m"
# fi
# fi
# Check if poetry command available or not
if ! type poetry > /dev/null 2>&1
then
# Install poetry
echo -e "\033[46mInstalling poetry\033[0m"
curl -sSL https://install.python-poetry.org | python3 -
if type poetry > /dev/null 2>&1
then
echo -e "\033[46;1mPoetry successfully installed\033[0m"
else
echo -e "\033[41;1mInstallation failed\033[0m"
exit 1
fi
fi
# Change-directory to the current package
# *In case this script is executed from other directory, pyproject.toml won't be found
package_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${package_dir}
# To manage global python environment
poetry config virtualenvs.create false --local
# If the package doesn't contain pyproject.toml, create it
if ! poetry check > /dev/null 2>&1
then
echo -e "\033[46mInitialize virtual environment\033[0m"
poetry init
echo -e "\033[46mVirtual environment created\033[0m"
else
echo -e "\033[46mValid pyproject.toml exists\033[0m"
fi
# Try poetry install command
if poetry install
then
echo -e "\033[46;1m===========================================\033[0m"
echo -e "\033[46;1m= Successfully installed the dependencies =\033[0m"
echo -e "\033[46;1m===========================================\033[0m"
else
echo -e "\033[46;1m======================================\033[0m"
echo -e "\033[46;1m= Installation failed, trying update =\033[0m"
echo -e "\033[46;1m======================================\033[0m"
# If poetry install failed, run poetry update
if poetry update
then
echo -e "\033[46;1m=========================================\033[0m"
echo -e "\033[46;1m= Successfully updated the dependencies =\033[0m"
echo -e "\033[46;1m=========================================\033[0m"
else
echo -e "\033[41;1m=========================================\033[0m"
echo -e "\033[41;1m= poetry failed to resolve dependencies =\033[0m"
echo -e "\033[41;1m=========================================\033[0m"
fi
fi
# For safety
poetry config virtualenvs.create true --local