!/usr/bin/env bash
author YuHaiPeng
yum install wget -y
yum update wget -y
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel glibc
if [ ! -f openssl-1.1.1u.tar.gz ];then
wget https://www.openssl.org/source/openssl-1.1.1u.tar.gz --no-check-certificate
fi
yum install repl* -y
tar -xvzf openssl-1.1.1u.tar.gz
cd openssl-1.1.1u
./config -fPIC --prefix=/usr/include/openssl enable-shared
make
make install
cd ../
file_python=$1
if [ -z $1 ];then
echo "参数为 python 包的文件的绝对路径"
exit 1
fi
if ! tar -zxvf $file_python &>/dev/null;then
echo "文件解压失败"
exit 2
fi
file_name=$(basename $file_python | sed 's/.tgz//')
echo "解压文件目录为 $file_name"
mkdir -p /usr/local/python3.11
cd $file_name
cd Modules
echo '_hashlib _hashopenssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) -l:libcrypto.a -Wl,--exclude-libs,libcrypto.a' >> Setup
echo '_ssl _ssl.c $(OPENSSL_INCLUDES) $(OPENSSL_LDFLAGS) -l:libssl.a -Wl,--exclude-libs,libssl.a -l:libcrypto.a -Wl,--exclude-libs,libcrypto.a' >> Setup
cd ../
./configure --prefix=/usr/local/python3.11 --with-zlib=/usr/include/ --with-openssl-rpath=auto --with-openssl=/usr/include/openssl OPENSSL_LDFLAGS=-L/usr/include/openssl OPENSSL_LIBS=-l/usr/include/openssl/ssl OPENSSL_INCLUDES=-I/usr/include/openssl && make && make install
if [ $? -ne 0 ];then
echo "编译文件失败"
exit 2
fi
if ! ln -s /usr/local/python3.11/bin/python3 /usr/bin/python3.11; then
echo "软连接创建失败"
exit
fi
grep "/usr/local/python3.11/bin" /etc/profile
if [ $? -ne 0 ];then
echo "PATH=$PATH:$HOME/bin:/usr/local/python3.11/bin" >> /etc/profile
source /etc/profile
fi
浙公网安备 33010602011771号