更新
This commit is contained in:
@@ -63,7 +63,8 @@ ADD Python-3.12.8.tar.xz /tmp/
|
||||
# 3) --with-system-ffi 使用系统 libffi,避免自编译
|
||||
# 4) --with-ensurepip=install 安装 pip
|
||||
# 5) 安装完成后对 Python 目录做「瘦身」:
|
||||
# - 删除 test/idlelib/tkinter/turtledemo/lib2to3/ensurepip 等运行时用不到的模块
|
||||
# - 删除 test/idlelib/tkinter/turtledemo/lib2to3 等运行时用不到的模块
|
||||
# - 保留 ensurepip 与 site-packages,否则 pip 会被一并删除
|
||||
# - 删除静态库 .a、libtool 文件 .la、__pycache__、.pyc
|
||||
# - 对 .so 执行 strip,去掉调试符号
|
||||
# 6) 最后删除源码目录,避免残留在 builder 层
|
||||
@@ -81,13 +82,16 @@ RUN set -eux; \
|
||||
make install; \
|
||||
\
|
||||
# ---- 裁剪 Python 安装目录,去掉运行时不需要的内容 ----
|
||||
# 注意:不要删 ensurepip,也不要删 site-packages/*
|
||||
# 否则 make install 阶段安装的 pip 会一起被删掉,
|
||||
# 导致 runtime 阶段 "No module named 'pip'"
|
||||
cd ${PYTHON_HOME}; \
|
||||
rm -rf lib/python3.12/test \
|
||||
lib/python3.12/idlelib \
|
||||
lib/python3.12/tkinter \
|
||||
lib/python3.12/turtledemo \
|
||||
lib/python3.12/lib2to3 \
|
||||
lib/python3.12/config-3.12-*;
|
||||
lib/python3.12/config-3.12-*; \
|
||||
# ---- 删除 Python 缓存文件 ----
|
||||
find ${PYTHON_HOME} -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null || true; \
|
||||
find ${PYTHON_HOME} -name '*.pyc' -delete; \
|
||||
|
||||
Reference in New Issue
Block a user