2

我正在尝试从fpectl启用模块的 Docker 容器内的源代码安装 Python 2.7.14。

使用官方的 Python jessie Dockerfile作为起点,我--with-fpectl在命令中添加了配置选项./configure

你可以在这个 gist中看到我的 docker build 命令的完整输出;然而,这里有一些有趣的地方:

./configure --build=x86_64-linux-gnu --enable-shared --enable-unicode=ucs4 --with-fpectl
...
checking for --with-fpectl... yes
...
x86_64-linux-gnu-gcc -pthread -fPIC -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -I/usr/include/x86_64-linux-gnu -I/usr/local/include -I/usr/src/python/Include -I/usr/src/python -c /usr/src/python/Modules/mathmodule.c -o build/temp.linux-x86_64-2.7/usr/src/python/Modules/mathmodule.o
In file included from Include/Python.h:156:0,
             from /usr/src/python/Modules/mathmodule.c:55:
/usr/src/python/Modules/mathmodule.c: In function ‘math_fsum’:
Include/pyfpe.h:164:64: warning: passing argument 1 of ‘PyFPE_dummy’ discards ‘volatile’ qualifier from pointer target type [-Wdiscarded-qualifiers]
 #define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v));
                                                                ^
/usr/src/python/Modules/mathmodule.c:1072:5: note: in expansion of macro ‘PyFPE_END_PROTECT’
     PyFPE_END_PROTECT(hi)
     ^
Include/pyfpe.h:134:15: note: expected ‘void *’ but argument is of type ‘volatile double *’
 extern double PyFPE_dummy(void *);
               ^
...
Python build finished, but the necessary bits to build these modules were not found:
bsddb185           dl                 imageop         
sunaudiodev                                           
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

(我实际上认为来自的错误消息mathmodule.c是良性的,但我认为我会将它包含在上下文中,因为它是似乎与fpectl模块相关的唯一其他输出。)

当我使用此构建创建的图像启动容器时,我有一个工作 Python 安装,但没有fpectl模块:

docker run -it <IMAGE ID> /bin/bash

root@54895ad345bb:/# python

Python 2.7.14 (default, Nov 16 2017, 02:12:20)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import fpectl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named fpectl

>>> import sysconfig
>>> print(sysconfig.get_config_var('CONFIG_ARGS'))
'--build=x86_64-linux-gnu' '--enable-shared' '--enable-unicode=ucs4' '--with-fpectl' 'build_alias=x86_64-linux-gnu'

>>> help("modules")

Please wait a moment while I gather a list of all available modules...

BaseHTTPServer      ast                 imghdr              sha
Bastion             asynchat            imp                 shelve
CDROM               asyncore            importlib           shlex
CGIHTTPServer       atexit              imputil             shutil
Canvas              audiodev            inspect             signal
ConfigParser        audioop             io                  site
Cookie              base64              itertools           smtpd
DLFCN               bdb                 json                smtplib
Dialog              binascii            keyword             sndhdr
DocXMLRPCServer     binhex              lib2to3             socket
FileDialog          bisect              linecache           spwd
FixTk               bsddb               linuxaudiodev       sqlite3
HTMLParser          bz2                 locale              sre
IN                  cPickle             logging             sre_compile
MimeWriter          cProfile            macpath             sre_constants
Queue               cStringIO           macurl2path         sre_parse
ScrolledText        calendar            mailbox             ssl
SimpleDialog        cgi                 mailcap             stat
SimpleHTTPServer    cgitb               markupbase          statvfs
SimpleXMLRPCServer  chunk               marshal             string
SocketServer        cmath               math                stringold
StringIO            cmd                 md5                 stringprep
TYPES               code                mhlib               strop
Tix                 codecs              mimetools           struct
Tkconstants         codeop              mimetypes           subprocess
Tkdnd               collections         mimify              sunau
Tkinter             colorsys            mmap                sunaudio
UserDict            commands            modulefinder        symbol
UserList            compileall          multifile           symtable
UserString          compiler            multiprocessing     sys
_LWPCookieJar       contextlib          mutex               sysconfig
_MozillaCookieJar   cookielib           netrc               syslog
__builtin__         copy                new                 tabnanny
__future__          copy_reg            nis                 tarfile
_abcoll             crypt               nntplib             telnetlib
_ast                csv                 ntpath              tempfile
_bisect             ctypes              nturl2path          termios
_bsddb              curses              numbers             textwrap
_codecs             datetime            opcode              this
_codecs_cn          dbhash              operator            thread
_codecs_hk          dbm                 optparse            threading
_codecs_iso2022     decimal             os                  time
_codecs_jp          difflib             os2emxpath          timeit
_codecs_kr          dircache            ossaudiodev         tkColorChooser
_codecs_tw          dis                 parser              tkCommonDialog
_collections        distutils           pdb                 tkFileDialog
_csv                doctest             pickle              tkFont
_ctypes             dumbdbm             pickletools         tkMessageBox
_ctypes_test        dummy_thread        pip                 tkSimpleDialog
_curses             dummy_threading     pipes               toaiff
_curses_panel       easy_install        pkg_resources       token
_elementtree        email               pkgutil             tokenize
_functools          encodings           platform            trace
_hashlib            ensurepip           plistlib            traceback
_heapq              errno               popen2              ttk
_hotshot            exceptions          poplib              tty
_io                 fcntl               posix               turtle
_json               filecmp             posixfile           types
_locale             fileinput           posixpath           unicodedata
_lsprof             fnmatch             pprint              unittest
_multibytecodec     formatter           profile             urllib
_multiprocessing    fpformat            pstats              urllib2
_osx_support        fractions           pty                 urlparse
_pyio               ftplib              pwd                 user
_random             functools           py_compile          uu
_socket             future_builtins     pyclbr              uuid
_sqlite3            gc                  pydoc               virtualenv
_sre                gdbm                pydoc_data          virtualenv_suppor
_ssl                genericpath         pyexpat             warnings
_strptime           getopt              quopri              wave
_struct             getpass             random              weakref
_symtable           gettext             re                  webbrowser
_sysconfigdata      glob                readline            wheel
_testcapi           grp                 repr                whichdb
_threading_local    gzip                resource            wsgiref
_tkinter            hashlib             rexec               xdrlib
_warnings           heapq               rfc822              xml
_weakref            hmac                rlcompleter         xmllib
_weakrefset         hotshot             robotparser         xmlrpclib
abc                 htmlentitydefs      runpy               xxsubtype
aifc                htmllib             sched               zipfile
antigravity         httplib             select              zipimport
anydbm              idlelib             sets                zlib
argparse            ihooks              setuptools
array               imaplib             sgmllib

补充说明

  • 我知道fpectl不鼓励使用该模块,并且它不存在于与官方 Python Docker 映像捆绑的 Python 构建中;但是,这是我的用例的要求(特别是使用针对 Python 安装编译的 Cython 模块的可操作性--with-fpectl,更多信息在这里这里)。

  • 看起来python通过 aptly 提供的软件包确实包含该fpectl模块(见下文)。但是,在这种情况下,出于各种原因(包括使用最新 2.7.x 的能力),我更喜欢从源代码构建。我试图检查用于 Python 包安装的配置选项,但在我自己的 Docker 构建中使用这些选项似乎也没有安装模块。

通过apt安装:

root@54895ad345bb:/# apt-get install -y python
...
root@54895ad345bb:/# /usr/bin/python

Python 2.7.9 (default, Jun 29 2016, 13:08:31)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> import fpectl
# no import error!

>>> import sysconfig
>>> print(sysconfig.get_config_var('CONFIG_ARGS'))
'--enable-shared' '--prefix=/usr' '--enable-ipv6' '--enable-unicode=ucs4' '--with-dbmliborder=bdb:gdbm' '--with-system-expat' '--with-system-ffi' '--with-fpectl' 'CC=x86_64-linux-gnu-gcc' 'CFLAGS=-D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-z,relro'

说了这么多,我错过了什么?是否需要一些额外的系统包来启用这个模块,或者在配置步骤中需要一些额外的标志?

4

0 回答 0