如何使用fpectl模块从源代码安装Python 2.7?

我试图从启用了fpectl模块的Docker容器中的源代码安装Python 2.7.14。

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

你可以在这个要点中看到我的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模块有关。

当我用这个版本创build的映像启动一个容器时,我有一个可用的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官方Python Docker镜像的捆绑中。 然而,这是我的使用案例(具体来说,使用--with-fpectl对照Python安装编译的Cython模块的可操作性, 这里和这里有更多的信息)的要求。

  • 它看起来像通过fpectl包含的python包包含fpectl模块(见下文)。 然而,在这种情况下,我宁愿从各种原因(包括使用最新的2.7.x的能力)从源生成。 我试图检查用于Python软件包安装的configuration选项,但在我自己的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' 

这么多, 我错过了什么? 是否有一些额外的系统包需要启用此模块,或在configuration步骤中需要一些额外的标志?