目录

Python3.11 源码编译

目录
 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
#!/bin/bash

# 指定安装路径
INSTALL_PATH=/opt/python3.11

# 下载和解压Python源码
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
tar -xf Python-3.11.0.tgz
cd Python-3.11.0

# 下载和解压OpenSSL源码
wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz
tar -xf openssl-1.1.1t.tar.gz
cd openssl-1.1.1t

# 配置OpenSSL
./config --prefix=$INSTALL_PATH --openssldir=$INSTALL_PATH/openssl

# 编译和安装OpenSSL
make && make install_sw

# 返回Python源码目录
cd ..

# 配置Python,指定使用OpenSSL 1.1.1t
./configure --prefix=$INSTALL_PATH LDFLAGS="-L$INSTALL_PATH/lib" CPPFLAGS="-I$INSTALL_PATH/include" --with-openssl=$INSTALL_PATH/openssl

# 编译和安装Python
make && make install

# 删除源码文件
cd ..
rm -rf Python-3.11.0
rm Python-3.11.0.tgz
rm -rf openssl-1.1.1t
rm openssl-1.1.1t.tar.gz

# 添加Python可执行文件路径到PATH环境变量
# ...