如何在高山容器中安装python2.6?

如何在高山docker集装箱中安装python2.6。

我试图从源代码安装,它给我编译错误。

其实我想在容器中安装Python2.6和Python2.7。 所以我可以在Python2.6和Python2.7上运行unittests。 请对此提出一些想法。

我已经安装了gcc,g ++,在阿尔派容器中做了下面的步骤。

wget https://www.python.org/ftp/python/2.6/Python-2.6.tgz tar xvzf Python-2.6.tgz cd Python-2.6 ./configure make 

在制作时得到这个错误,

 ~/Python-2.6 # make gcc -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/config.o Modules/config.c gcc -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -DPYTHONPATH='":plat-linux4:lib-tk:lib-old"' \ -DPREFIX='"/usr/local"' \ -DEXEC_PREFIX='"/usr/local"' \ -DVERSION='"2.6"' \ -DVPATH='""' \ -o Modules/getpath.o ./Modules/getpath.c gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o ./Modules/posixmodule.c:6173:1: error: conflicting types for 'posix_close' posix_close(PyObject *self, PyObject *args) ^ In file included from Include/Python.h:44:0, from ./Modules/posixmodule.c:30: /usr/include/unistd.h:38:5: note: previous declaration of 'posix_close' was here int posix_close(int, int); ^ Makefile:1234: recipe for target 'Modules/posixmodule.o' failed make: *** [Modules/posixmodule.o] Error 1 

任何人都可以提出如何解决这个问题?

对于python2.7,你可以使用frolvlad / alpine-python2 ,这是一个基于高山的50MB python2.7图片。

而对于python2.6,你可以得到Dockerfile并更新它,这样它也可以用于该版本

Docker有一个正式的回购 ,使用起来非常方便。 方便的是,有一个Python官方回购。 它具有不同版本的Python(包括2.7)和不同的基本操作系统(包括阿尔派)的图像。 我会build议使用官方的2.7阿尔法图像,并使用其Dockerfile作为安装Python 2.6的参考。

我也build议有单独的图像,一个与Python 2.6和2.7与2.7,而不是在同一个图像。 这将有助于避免必须并排安装/configuration两个不同版本的Python。


很难说没有看到Dockerfile的其余部分,为什么你的构build不工作,但是一个地方是构build依赖关系。 官方的Dockerfile在第37-53行增加了依赖关系,这个列表比你说的安装依赖更多。

我设法通过调整从这个问题的补丁工作: https : //bugs.python.org/issue20594到Python 2:

 --- ./Modules/posixmodule.c.orig +++ ./Modules/posixmodule.c @@ -3896,7 +3896,7 @@ #endif gid_t grouplist[MAX_GROUPS]; - /* On MacOSX getgroups(2) can return more than MAX_GROUPS results + /* On MacOSX getgroups(2) can return more than MAX_GROUPS results * This is a helper variable to store the intermediate result when * that happens. * @@ -6357,7 +6357,7 @@ Close a file descriptor (for low level IO)."); static PyObject * -posix_close(PyObject *self, PyObject *args) +posix_closex(PyObject *self, PyObject *args) { int fd, res; if (!PyArg_ParseTuple(args, "i:close", &fd)) @@ -8602,7 +8602,7 @@ {"tcsetpgrp", posix_tcsetpgrp, METH_VARARGS, posix_tcsetpgrp__doc__}, #endif /* HAVE_TCSETPGRP */ {"open", posix_open, METH_VARARGS, posix_open__doc__}, - {"close", posix_close, METH_VARARGS, posix_close__doc__}, + {"close", posix_closex, METH_VARARGS, posix_close__doc__}, {"closerange", posix_closerange, METH_VARARGS, posix_closerange__doc__}, {"dup", posix_dup, METH_VARARGS, posix_dup__doc__}, {"dup2", posix_dup2, METH_VARARGS, posix_dup2__doc__}, 

我发布我的完整的Dockerfile和补丁在这里:

https://gist.github.com/cwill747/722f41d8807c3b41a1e417849634cfe5