在Ubuntu中编译Python 2.6.6并需要外部软件包wxPython,setuptools等

在Ubuntu中编译Python 2.6.6并需要外部软件包wxPython,setuptools等,第1张

在Ubuntu中编译Python 2.6.6并需要外部软件包wxPython,setuptools等

一个好的一般经验法则是, 切勿 将默认系统安装的Python用于除杂项系统管理脚本之外的任何软件开发。这适用于所有UNIX,包括Linux和OS /
X。

相反,请使用所需的库(Python和C)构建一个由您控制的优秀Python发行版,并将此tarball安装在非系统目录中,例如/ opt / devpy或/
data / package / python或/ home /蟒蛇。当2.7.2可用时,为什么会搞乱2.6?

并且在构建它时,请确保其所有依赖项都在其自己的目录树(RPATH)中,并且将所有系统依赖项(.so文件)复制到其目录树中。这是我的版本。如果仅运行整个Shell脚本,则可能无法正常工作。我总是将其部分复制并粘贴到终端窗口中,并确认每个步骤都正常。确保将终端属性设置为允许多行回滚,或者一次仅粘贴几行。

(实际上,在进行了一些调整之后,我认为这可以作为脚本运行,但是我建议

./pybuild.sh >pylog2>&1
您使用类似的方法,以便您可以梳理输出并验证一切正常。

这是基于Ubuntu 64位构建的

#!/bin/bashshopt -s compat40export WGET=echo#uncomment the following if you are running for the first timeexport WGET=wgetsudo apt-get -y install build-essentialsudo apt-get -y install zlib1g-dev libxml2-dev libxslt1-dev libssl-dev libncurses5-dev sudo apt-get -y install libreadline6-dev autotools-dev autoconf automake libtoolsudo apt-get -y install libsvn-dev mercurial subversion git-coresudo apt-get -y install libbz2-dev libgdbm-dev sqlite3 libsqlite3-devsudo apt-get -y install curl libcurl4-gnutls-devsudo apt-get -y install libevent-dev libev-dev librrd4 rrdtoolsudo apt-get -y install uuid-dev libdb4.8-dev memcached libmemcached-dev sudo apt-get -y install libmysqlclient-dev libexpat1-devcd ~$WGET 'http://pre.google.com/p/google-perftools/downloads/detail?name=google-perftools-1.7.tar.gz'$WGET http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tgztar zxvf Python-2.7.2.tgzcd Python-2.7.2#following is needed if you have an old version of Mercurial installed#export HAS_HG=not-found# To provide a uniform build environmentunset PYTHonPATH PYTHonSTARTUP PYTHonHOME PYTHonCASEOK PYTHonIOENCODINGunset LD_RUN_PATH LD_LIBRARY_PATH LD_DEBUG LD_TRACE_LOADED_OBJECTS unset LD_PRELOAD SHLIB_PATH LD_BIND_NOW LD_VERBOSE## figure out whether this is a 32 bit or 64 bit systemm=`uname -m`if [[ $m =~ .*64 ]]; then   export CC="gcc -m64"    NBITS=64elif [[ $m =~ .*86 ]]; then   export CC="gcc -m32"   NBITS=32else # we are confused so bail out   echo $m   exit 1fi# some stuff related to distro independent build# extra_link_args = ['-Wl,-R/data1/python27/lib']#--enable-shared and a relative # RPATH[0] (eg LD_RUN_PATH='${ORIGIN}/../lib')export TARG=/data1/packages/python272export TCMALLOC_SKIP_SBRK=true#export CFLAGS='-ltcmalloc' # Google's fast mallocexport COMMonLDFLAGS='-Wl,-rpath,$$ORIGIN/../lib -Wl,-rpath-link,$$ORIGIN:$$ORIGIN/../lib:$$ORIGIN/../../lib -Wl,-z,origin -Wl,--enable-new-dtags'# -Wl,-dynamic-linker,$TARG/lib/ld-linux-x86-64.so.2export LDFLAGS=$COMMONLDFLAGS./configure --prefix=$TARG --with-dbmliborder=bdb:gdbm --enable-shared --enable-ipv6# if you have ia32-libs installed on a 64-bit system#export COMMonLDFLAGS="-L/lib32 -L/usr/lib32 -L`pwd`/lib32 -Wl,-rpath,$TARG/lib32 -Wl,-rpath,$TARG/usr/lib32"make# ignore failure to build the following since they are obsolete or deprecated# _tkinter bsddb185 dl imageop sunaudiodev#install it and collect any dependency libraries - not needed with RPATHsudo mkdir -p $TARGsudo chown `whoami`.users $TARGmake install# collect binary libraries ##REDO THIS IF YOU ADD ANY ADDITIonAL MODULES##function collect_binary_libs {cd $TARGfind . -name '*.so' | sed 's/^/ldd -v /' >elffilesecho "ldd -v bin/python" >>elffileschmod +x elffiles./elffiles | sed 's/.*=> //;s/ .*//;/:$/d;s/^   *//' | sort -u | sed 's/.*/cp -L & lib/' >lddinfo# mkdir libchmod +x lddinfo./lddinfocd ~}collect_binary_libs#set the pathcd ~export PATH=$TARG/bin:$PATH#installed setuptools$WGET http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.eggchmod +x setuptools-0.6c11-py2.7.egg./setuptools-0.6c11-py2.7.egg#installed virtualenvtar zxvf virtualenv-1.6.1.tar.gzcd virtualenv-1.6.1python setup.py installcd ~# created a base virtualenv that should work for almost all projects# we make it relocatable in case its location in the filesystem changes.cd ~python virtualenv-1.6.1/virtualenv.py /data1/py27base # first make itpython virtualenv-1.6.1/virtualenv.py --relocatable  /data1/py27base #then relocatabilize# check it outsource ~/junk/bin/activatepython --version# fill the virtualenv with useful modules# watch out for binary builds that may have dependency problemsexport LD_RUN_PATH='$$ORIGIN:$$ORIGIN/../lib:$$ORIGIN/../../lib'easy_install pippip install cythonpip install lxmlpip install httplib2pip install python-memcachedpip install amqplibpip install kombupip install carrotpip install py_eventsocketpip install haigha# extra escaping of $ signsexport LDFLAGS='-Wl,-rpath,$$$ORIGIN/../lib:$$$ORIGIN/../../lib -Wl,-rpath-link,$$$ORIGIN/../lib -Wl,-z,origin -Wl,--enable-new-dtags'# even more complex to build this one since we need some autotools and# have to pull source from a repositorymkdir rabbitccd rabbitchg clone http://hg.rabbitmq.com/rabbitmq-pregen/hg clone http://hg.rabbitmq.com/rabbitmq-c/cd rabbitmq-cautoreconf -imake clean./configure --prefix=/usrmakesudo make installcd ~# for zeromq we get the latest source of the library$WGET http://download.zeromq.org/zeromq-2.1.7.tar.gztar zxvf zeromq-2.1.7.tar.gzcd zeromq-2.1.7make clean./configure --prefix=/usrmakesudo make installcd ~# need less escaping of $ signsexport LDFLAGS='-Wl,-rpath,$ORIGIN/../lib:$ORIGIN/../../lib -Wl,-rpath-link,$ORIGIN/../lib -Wl,-z,origin -Wl,--enable-new-dtags'pip install pyzmqpip install pylibrabbitmq # need to build C library and install firstpip install pylibmcpip install pycurlexport LDFLAGS=$COMMonLDFLAGSpip install cherrypypip install pyopenssl # might need some ldflags on this one?pip install dieselpip install eventletpip install fapws3pip install geventpip install botopip install jinja2pip install makopip install pastepip install twistedpip install fluppip install pikapip install pymysql# pip install py-rrdtool # not on 64 bit???pip install PyRRDpip install tornadopip install redis# for tokyocabinet we need the latest source of the library$WGET http://fallabs.com/tokyocabinet/tokyocabinet-1.4.47.tar.gztar zxvf tokyocabinet-1.4.47.tar.gzcd tokyocabinet-1.4.47make clean./configure --prefix=/usr --enable-develmakesudo make installcd ..$WGET http://fallabs.com/tokyotyrant/tokyotyrant-1.1.41.tar.gztar zxvf tokyotyrant-1.1.41.tar.gzcd tokyotyrant-1.1.41make clean./configure --prefix=/usr --enable-develmakesudo make installcd ..pip install tokyo-pythonpip install solrpypip install pysolrpip install sunburntpip install txamqppip install littlechefpip install PyChefpip install pyvbpip install bottlepip install werkzeugpip install BeautifulSouppip install XSLToolspip install numpypip install coveragepip install pylint# pip install PyChecker  ???pip install pycallgraphpip install mkprepip install pydotpip install sqlalchemypip install buzhugpip install flaskpip install restezpip install pytzpip install mcdict# need less escaping of $ signspip install py-interface# pip install paramiko # pulled in by another modulepip install pexpect# SVN interface$WGET http://pysvn.barrys-emacs.org/source_kits/pysvn-1.7.5.tar.gztar zxvf pysvn-1.7.5.tar.gzcd pysvn-1.7.5/Sourcepython setup.py backportpython setup.py configuremakecd ../Testsmakecd ../Sourcesmkdir -p $TARG/lib/python2.7/site-packages/pysvncp pysvn/__init__.py $TARG/lib/python2.7/site-packages/pysvncp pysvn/_pysvn_2_7.so $TARG/lib/python2.7/site-packages/pysvncd ~# pip install protobuf #we have to do this the hard way$WGET http://protobuf.googlepre.com/files/protobuf-2.4.1.zipunzip protobuf-2.4.1.zipcd protobuf-2.4.1make clean./configure --prefix=/usrmakesudo make installcd pythonpython setup.py installcd ~pip install riakpip install ptracepip install html5libpip install metrics#redo the "install binary libraries" stepcollect_binary_libs# link binaries in the lib directory to avoid search path errors and also# to reduce the number of false starts to find the libraryfor i in `ls $TARG/lib/python2.7/lib-dynload/' |sort -u |grep -v 'dynload' |grep '.so' >straced.txt# ls -1d /data1/packages/python272/lib/* |sort -u >lib.txt# then examine the strace output to see how many places it searches before finding it.# a successful library load will be a call to open that doesn't end with ' = -1'# If it takes too many tries to find a particular library, then another symbolic link may # be a good idea


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5508459.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-13
下一篇 2022-12-13

发表评论

登录后才能评论

评论列表(0条)

保存