找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 18062|回复: 39

编译gevent1.0rc2+python2.7环境并且gae2.1最新1月3好更新

  [复制链接]
在gevent中主要使用Greenlet,给Python提供一个轻量级的协同程序,作为一个C的扩展模块.Greenlets主程序运行的所有系统进程是合理安排的. 这不同于任何multiprocessing或者multithreading提供的库和POSIX线程,这是真正的并行多处理器或多线程库提供真正的并行结构
首先感谢https://maskv.com/technology/192.html作者给我的帮助我参考老方法编译gevent1.0rc2成功但是无法运行gae最新版只能运行2.17原因就是缺少python2.7的支持现在博主给出啦方法搬过来方便大家

Tomato中python2.7+gevent1.0rc2环境的搭建
之前因为没有搜索到在Tomato中编译安装gevent的教程,就自己琢磨出来Tomato中python2.6+gevent0.13.8环境的搭建方法(点击这里查看),文章发布之后收到了众多的反馈。虽然Python官网当中的gevent最新版本为0.13.8,但Github上的gevent源码已经更新到了1.0rc2,最新版的gae本地客户端也集成的是gevent1.0rc2,在整合了一些反馈之后,在自己的路由器上成功更新了python和gevent。
首先卸载路由当中的python2.6及其相关组件,运行:
1
2
3

ipkg -force-removal-of-dependent-packages remove python26
rm -rf /opt/local/lib/python2.6 #若挂载路径非/opt请自行修改
rm -rf /opt/lib/python2.6

之后更新、安装所需要的依赖包:
1
2
3

ipkg update
ipkg upgrade
ipkg install busybox buildroot make grep openssl openssl-dev libuclibc++ wget-ssl python27 py27-setuptools

安装完成之后,我们要修复几个py27-setuptools当中的小错误。

首先easy_install的安装路径莫名其妙的指向了python2.5,不知是否只有我遇到了这个问题。修改 /opt/lib/python2.7/distutils/distutils.cfg 文件,将
1

site-dirs  = /opt/local/lib/python2.5/site-packages

修改为
1

site-dirs  = /opt/local/lib/python2.7/site-packages

其次easy_install的安装临时目录指向了/tmp目录,会造成安装某些组件时tmp剩余空间不足而导致的安装失败,我们要手动将其指定到挂载的U盘当中。
在/opt中创建tmp文件夹,修改 /opt/lib/python2.7/site-packages/setuptools/command/easy_install.py 文件,找到412行:
1

tmpdir = tempfile.mkdtemp(prefix="easy_install-")

将其修改为:
1

tmpdir = tempfile.mkdtemp(prefix="easy_install-",dir="/opt/tmp")

然后就可以使用easy_install安装greenlet与cython了(此步骤花费时间奇长无比):
1
2
3
4

easy_install-2.7 greenlet
easy_install-2.7 cython
ln -s /opt/local/bin/cygdb /opt/bin/cygdb
ln -s /opt/local/bin/cython /opt/bin/cython

之后下载gevent:
1
2
3
4

cd /opt
/opt/bin/wget https://github.com/downloads/Sit ... event-1.0rc2.tar.gz --no-check-certificate
tar zxvf gevent-1.0rc2.tar.gz
cd gevent-1.0rc2

直接编译会报错,因为使用了mips2的sync指令,在gae的issues上找到了答案。心得编译前记得开启虚拟内存
修改 /libev/ev.c 文件,找到604行的:参考
https://code.google.com/p/gae/issues/detail?id=7823
1

#define ECB_MEMORY_FENCE         __asm__ __volatile__ ("sync"     : : : "memory")

修改为:
1

#define ECB_MEMORY_FENCE         __asm__ __volatile__ (".set mips2; sync; .set mips0": : :"memory")

执行
1

python2.7 setup.py install

下载并安装pyOpenSSL
1
2
3
4
5

cd /opt
wget http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.12.tar.gz
tar zxvf pyOpenSSL-0.12.tar.gz
cd pyOpenSSL-0.12
python2.7 setup.py install

安装结束之后,运行gae可能会提示.python-eggs错误,我们可以手动指定缓存目录。
修改gae的proxy.py文件,在:
1

import os

下一行添加:
1

os.environ['PYTHON_EGG_CACHE'] = '/opt/.python-eggs'

或者可以将 gevent-1.0rc2-py2.7-linux-mips.egg 解包:
1
2
3
4
5

cd /opt/local/lib/python2.7/site-packages
mv gevent-1.0rc2-py2.7-linux-mips.egg gevent-1.0rc2-py2.7-linux-mips.egg.zip
mkdir gevent-1.0rc2-py2.7-linux-mips.egg
cd gevent-1.0rc2-py2.7-linux-mips.egg
unzip /opt/local/lib/python2.7/site-packages/gevent-1.0rc2-py2.7-linux-mips.egg.zip

再次运行gae,应该不会再有错误提示了。

easy_install-2.7 cython过程漫长rg200e历时大概8个多小时完成安装大家耐心等待教程是没有问题的


Using /opt/local/lib/python2.7/site-packages/greenlet-0.4.0-py2.7-linux-mips.egg
Processing dependencies for greenlet
Finished processing dependencies for greenlet
root@Tomato-arctic:/tmp/home/root# easy_install-2.7 cython
Searching for cython
Reading http://pypi.python.org/simple/cython/
Reading http://www.cython.org
Reading http://cython.org
Best match: Cython 0.17.3
Downloading http://cython.org/release/Cython-0.17.3.zip
Processing Cython-0.17.3.zip
Running Cython-0.17.3/setup.py -q bdist_egg --dist-dir /opt/tmp/easy_install-hCF
2Og/Cython-0.17.3/egg-dist-tmp-Y0XMdp
Compiling module Cython.Plex.Scanners ...
Compiling module Cython.Plex.Actions ...
Compiling module Cython.Compiler.Lexicon ...
Compiling module Cython.Compiler.Scanning ...
Compiling module Cython.Compiler.Parsing ...
Compiling module Cython.Compiler.Visitor ...
Compiling module Cython.Compiler.FlowControl ...
Compiling module Cython.Compiler.Code ...
Compiling module Cython.Runtime.refnanny ...
warning: no files found matching '*.pyx' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.h' under directory 'Cython/Debugger/Tests'
warning: no files found matching '*.pxd' under directory 'Cython/Utility'
/opt/tmp/easy_install-hCF2Og/Cython-0.17.3/Cython/Plex/Scanners.c:7091: warning:
'__Pyx_CyFunction_New' defined but not used
Adding Cython 0.17.3 to easy-install.pth file
Installing cygdb script to /opt/local/bin
Installing cython script to /opt/local/bin

Installed /opt/local/lib/python2.7/site-packages/Cython-0.17.3-py2.7-linux-mips.
egg
Processing dependencies for cython
Finished processing dependencies for cython
root@Tomato-arctic:/tmp/home/root# ln -s /opt/local/bin/cygdb /opt/bin/cygdb
ln: /opt/bin/cygdb: File exists
root@Tomato-arctic:/tmp/home/root# ln -s /opt/local/bin/cython /opt/bin/cython
ln: /opt/bin/cython: File exists
root@Tomato-arctic:/tmp/home/root#









评分

参与人数 2恩山币 +4 收起 理由
jzm*** + 1 本人看到有最有技术含量的技术贴之一,有之一
54*** + 3 编译好的二进制文件,能打包共享下吗?谢谢

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.

谢谢分享,收下备用!!!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

{:soso_e117:}要是图文并茂,再详细点就更好了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

学习一下~~~~~~~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

这个的作用是什么啊,为小白解释下啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

感谢楼主放出教程,我就不折腾了,反正没有gevent现在goagent也可以用
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报


感谢楼主放出教程,
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
怎么打包啊 我也不会 我现在也遇到个奇怪的问题 就是用2.17版本没问题 2.19版本就有问题出错
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
学习下。上次看一个教程没有成功。明天试下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

每次到安装easy_install-2.7 cython
这一步都过不去,什么情况??
求解?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

damnsoul 发表于 2012-12-29 00:27
每次到安装easy_install-2.7 cython
这一步都过不去,什么情况??
求解?

我遇到的问题和你一样~~ 求解
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
本帖最后由 jxl0421 于 2012-12-29 02:08 编辑

先在
/opt中创建tmp文件夹然后 这样就可以啦 你应该没看到我用红字写的那个
easy_install-2.7 greenlet
easy_install-2.7 cython
ln -s /opt/local/bin/cygdb /opt/bin/cygdb
ln -s /opt/local/bin/cython /opt/bin/cython
这样四句一起运行看看
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
我的记得好像也出错过好像是东西复制的不对 在我的上面运行啦一次命令没错
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

我就是按照你的教程步骤做的 ,遇到的问题和11楼的一样~~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

太感谢了,找了好久终于解决了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-27 07:18

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表