cx_Freeze打包gevent时遇到的问题

October 8th, 2011

写python就是个玩蛋的活,还是cx_Freeze,在mac osx下打包gevent程序提示无法import的错误,gevent,greenlet都是easy_install安装的,程序里引入木有问题的,只有cx_Freeze打包时提示错误。

鉴于之前的经验,这次没作无谓的抵抗,直接去cx_Freeze的源代码里调试,几经折腾发现cx_Freeze这厮是不能从包好的egg里import的,在Freebsd环境下easy_install安装后的egg其实是个文件夹,而在mac osx和windows下egg是个压缩包,于是将egg原地敲碎释放在site-package目录下就好了。

顺便处理一个小warnning

/Users/zhangdi/Downloads/test/gevent_test/output/dist/main/gevent/socket.py:788: DeprecationWarning: gevent.sslold is deprecated; use gevent.ssl instead (install ssl package from PyPI)
直接去代码里改一下就可以了

cx_Freeze在freebsd下恼人的问题

October 7th, 2011
在64位freebsd7.3中用cx_Freeze打包时遇到的问题
Traceback (most recent call last):
 ....
     import socket
  File "/usr/local/lib/python2.6/socket.py", line 64, in <module>
    from _ssl import SSLError as sslerror
ImportError: cannot import name SSLError
一顿找原因啊,google啊啥的各种无解啊。最后无奈看了下socket.py的源码
try:
    import _ssl
except ImportError:
    # no SSL support
    pass  嗯嗯,很好,这里pass了
else:
还好如果import不到的话pass了,于是乎,我很可耻的excludes掉了ssl
buildOptions = dict(
        compressed = True,
        optimize = 1,
        includes = ["_ctypes", "socket", '_socket', ],
        excludes = ['ssl', '_ssl', ],
        path = sys.path + ["modules"]
    )

				

freebsd amd64安装vmware-tools

August 24th, 2011

freebsd7.3 amd64

最小化安装,ports安装perl

点vmware菜单install vmware-tools。

然后mount /cdrom

解压缩/cdrom里的文件到其他目录,俺放到/tmp下了。

运行安装脚本,脚本的默认perl路径是/usr/bin/perl,默认ports按照到/usr/local/bin/perl呢,ln一下,安装过程中还有个pl脚本呢,改pl文件就不那么方便。

64位系统提示需要安装compat6x-amd64

pkd_add -r compat6x-amd64安装一下。

重新之行脚本,安装完成。

macports安装scapy遇到滴问题

January 28th, 2011
公司的无线慢得令人发指,再几次掉线后出现了这样的错误
DEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
—>  Checksumming atlas3.8.3.tar.bz2
Error: Target org.macports.checksum returned: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
DEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas
while executing
“$procedure $targetname”
Warning: the following items did not execute (for atlas): org.macports.activate org.macports.checksum org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.install
Log for atlas is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_atlas/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>
zhangdi:local$ sudo port clean –all atlas
—>  Cleaning atlas
zhangdi:local$ port clean –all atlas
—>  Cleaning atlas
Warning: Only cleaning in ~/.macports; insufficient privileges for standard locations
zhangdi:local$ sudo port install atlas
—>  Computing dependencies for atlas
—>  Fetching atlas
—>  Attempting to fetch atlas3.8.3.tar.bz2 from http://downloads.sourceforge.net/math-atlas
—>  Attempting to fetch lapack-3.2.2.tgz from http://www.netlib.org/lapack

—>  Checksumming atlas3.8.3.tar.bz2Error: Target org.macports.checksum returned: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlasDEBUG: Backtrace: atlas3.8.3.tar.bz2 does not exist in /opt/local/var/macports/distfiles/atlas    while executing”$procedure $targetname”Warning: the following items did not execute (for atlas): org.macports.activate org.macports.checksum org.macports.extract org.macports.patch org.macports.configure org.macports.build org.macports.destroot org.macports.installLog for atlas is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_math_atlas/main.logError: Status 1 encountered during processing.To report a bug, see <http://guide.macports.org/#project.tickets>zhangdi:local$ sudo port clean –all atlas—>  Cleaning atlaszhangdi:local$ port clean –all atlas—>  Cleaning atlasWarning: Only cleaning in ~/.macports; insufficient privileges for standard locationszhangdi:local$ sudo port install atlas—>  Computing dependencies for atlas—>  Fetching atlas—>  Attempting to fetch atlas3.8.3.tar.bz2 from http://downloads.sourceforge.net/math-atlas—>  Attempting to fetch lapack-3.2.2.tgz from http://www.netlib.org/lapack

clean 一下就好了

参考 https://trac.macports.org/ticket/27542

sphinx的autodoc

January 24th, 2011

修改conf.py 先把项目目录加上

sys.path.append(os.path.abspath(‘d:/wsgi/biz_python’))

# — General configuration —————————————————–

添加扩展 sphinx.ext.autodoc
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named ‘sphinx.ext.*’) or your custom ones.
extensions = ['sphinx.ext.autodoc']

这就可以用了,在文档使用吧

.. function:: foo(x)
foo(y, z)
:module: some.module.name

Return a line of text input from the user.