我试图在Ubuntu 10.4上编译
Python 2.7,但是在运行make后会收到以下错误消息:
Python build finished,but the necessary bits to build these modules were not found: _bsddb bsddb185 sunaudiodev To find the necessary bits,look in setup.py in detect_modules() for the module's name.
我需要什么包? (setup.py无效)
假设您已经安装了所有依赖项(在Ubuntu上,这将是一堆诸如sudo apt-get install libdb4.8-dev和各种其他的-dev软件包,那么我是如何构建Python的.
tar zxvf Python-2.7.1.tgz cd Python-2.7.1 # 64 bit self-contained build in /opt export TARG=/opt/python272 export CC="gcc -m64" export LDFLAGS='-Wl,-rpath,\$${ORIGIN}/../lib -Wl,-rpath-link,--enable-new-dtags' ./configure --prefix=$TARG --with-dbmliborder=bdb:gdbm --enable-shared --enable-ipv6 make make install
在制作过程中不建立的唯一模块有:
_tkinter - I don't do GUI apps and would use wxWindows if I did bsddb185 - horribly obsolete version of bdb dl - deprecated in 2.6 imageop - deprecated in 2.6 sunaudiodev - obsolete interface to some SparcStation device I think
接下来,我收集任何尚未安装在Python安装目录中的.so文件,然后将其复制:
# collect binary libraries ##REDO THIS IF YOU ADD ANY ADDITIONAL MODULES## cd /opt/python272 find . -name '*.so' | sed 's/^/ldd -v /' >elffiles echo "ldd -v bin/python" >>elffiles chmod +x elffiles ./elffiles | sed 's/.*=> //;s/ .*//;/:$/d;s/^ *//' | sort -u | sed 's/.*/cp -L & lib/' >lddinfo # mkdir lib chmod +x lddinfo ./lddinfo
然后添加setuptools的很好的措施
#set the path export PATH=/opt/python272/bin:$PATH #install setuptools ./setuptools-0.6c11-py2.7.egg
在这一点上,我可以使用/ opt / python272的tarball,并在任何64位的Linux发行版上运行,甚至是一个没有安装任何依赖关系的剥离版,也可以是旧的旧版旧版本的依赖关系.
我也得到点安装,但在这一点上,由于与virtualenv的一些失败的斗争,笔记中有一个缺口.基本上virtualenv不支持这种情况.大概我做了easy_install点,然后:
export LD_RUN_PATH=\$${ORIGIN}/../lib pip install cython pip install {a whole bunch of other libraries that I expect to use}
完成安装模块后,我返回并重新运行命令来收集.so文件,并创建一个新的tarball.有几个包,我不得不用LDFLAGS来处理它们,以使它们正确安装,而且我还没有做足够的彻底的测试,但到目前为止,它的工作原理是,我使用这个Python构建来运行生产应用程序未安装所有支持库的计算机.