1 Star 0 Fork 23

zhangbo36/openharmony_oneclick_env_init

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install_python.sh 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
mamingshuai 提交于 2021-08-12 01:54 . update install_python.sh.
#!/bin/bash
baseDirForScriptSelf=$(cd "$(dirname "$0")"; pwd)
source ${baseDirForScriptSelf}/source.sh
unset http_proxy
unset https_proxy
is_huawei_tmp=`curl -I -m 10 -o /dev/null -s -w %{http_code} w3.huawei.com`
if [ "${is_huawei_tmp}" == "200" ];then
is_huawei=true
else
is_huawei=false
fi
## 内网不需要配置代理
if [ "${is_huawei}" == "true" ];then
unset http_proxy;unset https_proxy
else
source ${baseDirForScriptSelf}/proxy.sh
fi
# 准备python3,20.04默认是3.8.x
os_type=`lsb_release -i|awk '{print $NF}'|tr '[A-Z]' '[a-z]'`
if [ "${os_type}" == 'ubuntu' ];then
sudo bash -c "apt-get install -y python3.8 >>${baseDirForScriptSelf}/init_run.log 2>&1"
else
echo "${os_type} 系统需要源码编译python3.8"
unset http_proxy
unset https_proxy
sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl
cd ${work_dir}
source ${baseDirForScriptSelf}/proxy.sh
curl -s -k -L --retry 5 "https://repo.huaweicloud.com/python/3.8.0/Python-3.8.0.tar.xz" --output "Python-3.8.0.tar.xz"
sudo tar Jxvf Python-3.8.0.tar.xz
cd Python-3.8.0
sudo ./configure #--enable-optimizations
sudo make
sudo make install
sudo ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.8/site-packages/lsb_release.py
fi
python_file=`which python 2>&1|grep -v which`
python38_file=`which python3.8 2>&1|grep -v which`
sudo bash -c "update-alternatives --install ${python_file} python ${python38_file} 1 >>${baseDirForScriptSelf}/init_run.log 2>&1"
sudo bash -c "update-alternatives --install ${python_file}3 python3 ${python38_file} 1 >>${baseDirForScriptSelf}/init_run.log 2>&1"
sudo bash -c "apt-get install -y python3-setuptools python3-pip -y >>${baseDirForScriptSelf}/init_run.log 2>&1"
python3.8 -m pip install --upgrade pip >>${baseDirForScriptSelf}/init_run.log 2>&1
python3.8 -m pip install ecdsa Crypto pycryptodome pycryptodomex >>${baseDirForScriptSelf}/init_run.log 2>&1
# 解决ModuleNotFoundError: No module named 'apt_pkg'
sudo bash -c " apt install -y python3-apt >>${baseDirForScriptSelf}/init_run.log 2>&1"
cd /usr/lib/python3/dist-packages/
sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so
# 判断python版本是否满足3.7+要求
python_version=`python3.8 --version|awk '{print $2}'|sed 's/\.//g'`
if [ ${python_version//./} -ge 370 ];then
echo -e "${success_color},Python version ${python_version}"
else
echo -e "${failed_color},Python version Check Failed"
exit 1
fi
source /etc/profile
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangbo36/openharmony_oneclick_env_init.git
git@gitee.com:zhangbo36/openharmony_oneclick_env_init.git
zhangbo36
openharmony_oneclick_env_init
openharmony_oneclick_env_init
master

搜索帮助