Windows10 + VMware + Ubuntu20.04 + Docker20.10.7
源码:python3.10.2
$ mkdir build-python$ cd build-python$ wget https://www.python.org/ftp/python/3.9.10/Python-3.9.10.tgz
三、构建编译环境 3.1 编写Dockerfile文件$ vi Dockerfile
FROM ubuntuRUN apt update && apt install gcc -y && apt install make -y && apt install libffi-dev -y
3.2 构建编译环境镜像$ docker build 、-t build-python
$ docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEbuild-python latest b3483e995f0e 24 seconds ago 237MBubuntu latest d13c942271d6 4 weeks ago 72.8MB
四、编译源码 4.1 启动容器$ pwd/home/tree/code/build-python$ lsDockerfile Python-3.10.2.tgz
$ docker run -itd -v /home/tree/code/build-python:/root --name build-python build-python /bin/bash
获取容器id
$ docker ps -aConTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMESee2622dd7c8b build-python "/bin/bash" 5 seconds ago Up 4 seconds build-python
4.2 进入容器$ docker exec -it ee2622dd7c8b /bin/bash
4.3 编译root@ee2622dd7c8b:/# cd /rootroot@ee2622dd7c8b:~# tar xf Python-3.9.10.tgzroot@ee2622dd7c8b:~# cd Python-3.9.10root@ee2622dd7c8b:~# ./configure --with-pydebugroot@ee2622dd7c8b:~# make
注意:只编译了核心的模块代码,对于_curses,_ssl等一些外围模块没编译。