Spaces:
Sleeping
Sleeping
update
Browse files- install.sh +72 -0
- script/install_python.sh +129 -0
install.sh
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
# sh install.sh --stage 2 --stop_stage 2 --system_version centos
|
4 |
+
|
5 |
+
python_version=3.8.10
|
6 |
+
system_version=centos
|
7 |
+
|
8 |
+
verbose=true;
|
9 |
+
stage=-1
|
10 |
+
stop_stage=0
|
11 |
+
|
12 |
+
|
13 |
+
# parse options
|
14 |
+
while true; do
|
15 |
+
[ -z "${1:-}" ] && break; # break if there are no arguments
|
16 |
+
case "$1" in
|
17 |
+
--*) name=$(echo "$1" | sed s/^--// | sed s/-/_/g);
|
18 |
+
eval '[ -z "${'"$name"'+xxx}" ]' && echo "$0: invalid option $1" 1>&2 && exit 1;
|
19 |
+
old_value="(eval echo \\$$name)";
|
20 |
+
if [ "${old_value}" == "true" ] || [ "${old_value}" == "false" ]; then
|
21 |
+
was_bool=true;
|
22 |
+
else
|
23 |
+
was_bool=false;
|
24 |
+
fi
|
25 |
+
|
26 |
+
# Set the variable to the right value-- the escaped quotes make it work if
|
27 |
+
# the option had spaces, like --cmd "queue.pl -sync y"
|
28 |
+
eval "${name}=\"$2\"";
|
29 |
+
|
30 |
+
# Check that Boolean-valued arguments are really Boolean.
|
31 |
+
if $was_bool && [[ "$2" != "true" && "$2" != "false" ]]; then
|
32 |
+
echo "$0: expected \"true\" or \"false\": $1 $2" 1>&2
|
33 |
+
exit 1;
|
34 |
+
fi
|
35 |
+
shift 2;
|
36 |
+
;;
|
37 |
+
|
38 |
+
*) break;
|
39 |
+
esac
|
40 |
+
done
|
41 |
+
|
42 |
+
work_dir="$(pwd)"
|
43 |
+
data_dir="$(pwd)/data"
|
44 |
+
|
45 |
+
mkdir -p "${data_dir}"
|
46 |
+
|
47 |
+
|
48 |
+
if [ ${system_version} = "centos" ]; then
|
49 |
+
yum install -y bzip2 git lrzsz wget vim cronie
|
50 |
+
elif [ ${system_version} = "ubuntu" ]; then
|
51 |
+
apt-get install -y bzip2 git lrzsz wget vim cron
|
52 |
+
fi
|
53 |
+
|
54 |
+
|
55 |
+
if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
|
56 |
+
$verbose && echo "stage 1: install python"
|
57 |
+
cd "${work_dir}" || exit 1;
|
58 |
+
|
59 |
+
sh ./script/install_python.sh --python_version "${python_version}" --system_version "${system_version}"
|
60 |
+
|
61 |
+
fi
|
62 |
+
|
63 |
+
|
64 |
+
if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
|
65 |
+
$verbose && echo "stage 2: create virtualenv"
|
66 |
+
/usr/local/python-${python_version}/bin/pip3 install virtualenv
|
67 |
+
mkdir -p /data/local/bin
|
68 |
+
cd /data/local/bin || exit 1;
|
69 |
+
# source /data/local/bin/ASR/bin/activate
|
70 |
+
/usr/local/python-${python_version}/bin/virtualenv ASR
|
71 |
+
|
72 |
+
fi
|
script/install_python.sh
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
# 参数:
|
4 |
+
python_version="3.6.5";
|
5 |
+
system_version="centos";
|
6 |
+
|
7 |
+
|
8 |
+
# parse options
|
9 |
+
while true; do
|
10 |
+
[ -z "${1:-}" ] && break; # break if there are no arguments
|
11 |
+
case "$1" in
|
12 |
+
--*) name=$(echo "$1" | sed s/^--// | sed s/-/_/g);
|
13 |
+
eval '[ -z "${'"$name"'+xxx}" ]' && echo "$0: invalid option $1" 1>&2 && exit 1;
|
14 |
+
old_value="(eval echo \\$$name)";
|
15 |
+
if [ "${old_value}" == "true" ] || [ "${old_value}" == "false" ]; then
|
16 |
+
was_bool=true;
|
17 |
+
else
|
18 |
+
was_bool=false;
|
19 |
+
fi
|
20 |
+
|
21 |
+
# Set the variable to the right value-- the escaped quotes make it work if
|
22 |
+
# the option had spaces, like --cmd "queue.pl -sync y"
|
23 |
+
eval "${name}=\"$2\"";
|
24 |
+
|
25 |
+
# Check that Boolean-valued arguments are really Boolean.
|
26 |
+
if $was_bool && [[ "$2" != "true" && "$2" != "false" ]]; then
|
27 |
+
echo "$0: expected \"true\" or \"false\": $1 $2" 1>&2
|
28 |
+
exit 1;
|
29 |
+
fi
|
30 |
+
shift 2;
|
31 |
+
;;
|
32 |
+
|
33 |
+
*) break;
|
34 |
+
esac
|
35 |
+
done
|
36 |
+
|
37 |
+
echo "python_version: ${python_version}";
|
38 |
+
echo "system_version: ${system_version}";
|
39 |
+
|
40 |
+
|
41 |
+
if [ ${system_version} = "centos" ]; then
|
42 |
+
# 安装 python 开发编译环境
|
43 |
+
yum -y groupinstall "Development tools"
|
44 |
+
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
|
45 |
+
yum install libffi-devel -y
|
46 |
+
yum install -y wget
|
47 |
+
yum install -y make
|
48 |
+
|
49 |
+
mkdir -p /data/dep
|
50 |
+
cd /data/dep || exit 1;
|
51 |
+
if [ ! -e Python-${python_version}.tgz ]; then
|
52 |
+
wget -P /data/dep https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz
|
53 |
+
fi
|
54 |
+
|
55 |
+
cd /data/dep || exit 1;
|
56 |
+
if [ ! -d Python-${python_version} ]; then
|
57 |
+
tar -zxvf Python-${python_version}.tgz
|
58 |
+
cd /data/dep/Python-${python_version} || exit 1;
|
59 |
+
fi
|
60 |
+
|
61 |
+
mkdir /usr/local/python-${python_version}
|
62 |
+
./configure --prefix=/usr/local/python-${python_version}
|
63 |
+
make && make install
|
64 |
+
|
65 |
+
/usr/local/python-${python_version}/bin/python3 -V
|
66 |
+
/usr/local/python-${python_version}/bin/pip3 -V
|
67 |
+
|
68 |
+
rm -rf /usr/local/bin/python3
|
69 |
+
rm -rf /usr/local/bin/pip3
|
70 |
+
ln -s /usr/local/python-${python_version}/bin/python3 /usr/local/bin/python3
|
71 |
+
ln -s /usr/local/python-${python_version}/bin/pip3 /usr/local/bin/pip3
|
72 |
+
|
73 |
+
python3 -V
|
74 |
+
pip3 -V
|
75 |
+
|
76 |
+
elif [ ${system_version} = "ubuntu" ]; then
|
77 |
+
# 安装 python 开发编译环境
|
78 |
+
# https://zhuanlan.zhihu.com/p/506491209
|
79 |
+
|
80 |
+
# 刷新软件包目录
|
81 |
+
sudo apt update
|
82 |
+
# 列出当前可用的更新
|
83 |
+
sudo apt list --upgradable
|
84 |
+
# 如上一步提示有可以更新的项目,则执行更新
|
85 |
+
sudo apt -y upgrade
|
86 |
+
# 安装 GCC 编译器
|
87 |
+
sudo apt install gcc
|
88 |
+
# 检查安装是否成功
|
89 |
+
gcc -v
|
90 |
+
|
91 |
+
# 安装依赖
|
92 |
+
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libbz2-dev liblzma-dev sqlite3 libsqlite3-dev tk-dev uuid-dev libgdbm-compat-dev
|
93 |
+
|
94 |
+
mkdir -p /data/dep
|
95 |
+
cd /data/dep || exit 1;
|
96 |
+
if [ ! -e Python-${python_version}.tgz ]; then
|
97 |
+
# sudo wget -P /data/dep https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
|
98 |
+
sudo wget -P /data/dep https://www.python.org/ftp/python/${python_version}/Python-${python_version}.tgz
|
99 |
+
fi
|
100 |
+
|
101 |
+
cd /data/dep || exit 1;
|
102 |
+
if [ ! -d Python-${python_version} ]; then
|
103 |
+
# tar -zxvf Python-3.6.5.tgz
|
104 |
+
tar -zxvf Python-${python_version}.tgz
|
105 |
+
# cd /data/dep/Python-3.6.5
|
106 |
+
cd /data/dep/Python-${python_version} || exit 1;
|
107 |
+
fi
|
108 |
+
|
109 |
+
# mkdir /usr/local/python-3.6.5
|
110 |
+
mkdir /usr/local/python-${python_version}
|
111 |
+
|
112 |
+
# 检查依赖与配置编译
|
113 |
+
# sudo ./configure --prefix=/usr/local/python-3.6.5 --enable-optimizations --with-lto --enable-shared
|
114 |
+
sudo ./configure --prefix=/usr/local/python-${python_version} --enable-optimizations --with-lto --enable-shared
|
115 |
+
cpu_count=$(cat /proc/cpuinfo | grep processor | wc -l)
|
116 |
+
# sudo make -j 4
|
117 |
+
sudo make -j "${cpu_count}"
|
118 |
+
|
119 |
+
/usr/local/python-${python_version}/bin/python3 -V
|
120 |
+
/usr/local/python-${python_version}/bin/pip3 -V
|
121 |
+
|
122 |
+
rm -rf /usr/local/bin/python3
|
123 |
+
rm -rf /usr/local/bin/pip3
|
124 |
+
ln -s /usr/local/python-${python_version}/bin/python3 /usr/local/bin/python3
|
125 |
+
ln -s /usr/local/python-${python_version}/bin/pip3 /usr/local/bin/pip3
|
126 |
+
|
127 |
+
python3 -V
|
128 |
+
pip3 -V
|
129 |
+
fi
|