2016-11-27 17 views
0

如何在高山碼頭集裝箱中安裝python2.6。如何在高山容器中安裝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 

任何一個可以建議我怎麼能解決這個問題?

+1

不知道它會有幫助,但也許這將是值得一會看看如何高山用於構建2.6:http://git.alpinelinux.org/cgit/aports/tree/main/python?id=96e95a93287adc9c6bdf8689fa974b11d41dc492以及它們如何建立2.7 :http://git.alpinelinux.org/cgit/aports/樹/主/ python2。 – wrwrwr

回答

1

對於python2.7,你可以使用frolvlad/alpine-python2,這是一種基於高山一個50MB的python2.7圖像。

而對於python2.6的,你可以得到Dockerfile和更新,使之適用於該版本以及

1

碼頭工人有official repos,這是非常方便使用。方便,有一個python官方回購。它具有不同版本的Python(包括2.7)和不同基本操作系統(包括高山)的圖像。我會建議使用官方2.7 alphine圖像,並使用its Dockerfile作爲安裝Python 2.6的參考。

我還建議具有單獨的圖像,一個與Python 2.6和一個2.7,而不是兩者在同一圖像具有。這將有助於避免必須並排安裝/配置兩個不同版本的Python。


這很難說,爲什麼你的編譯沒有沒有看到你的Dockerfile的其他工作,但一個地方開始是建立依賴關係。官方Dockerfile增加了建立在線路37-53依賴性列表有比你說你安裝的那些更依賴。

1

我設法通過調整從這個問題的補丁得到這個工作: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