我真的很想为使用IronPython的项目使用出色的zerorpc,但似乎不支持它.
我尝试下载Zerorpc的源zip并运行
"C:\Program Files (x86)\IronPython 2.7\ipy.exe" setup.py install
但我一直看到:
warning: build_py: byte-compiling is disabled, skipping.
这并不与答案矛盾:Fast and scalable RPC between C# and CPython.
我的问题:
>是否可以让IronPython运行Zerorpc,如果可以,请给我一个提示.
>如果没有,那么是否还有其他等效的软件包可以在IronPython中提供功能?这里有一个列表:What is the current choice for doing RPC in Python?,但是有人知道其中任何一个是否可以与IronPython一起使用吗?
更新2
在@PawelJasinski建议和他对pyzmq ironpython-backend的更新之后,我尝试了以下方法:
>已安装IronPython 2.7.5b2或更高版本
>从http://zeromq.org/distro:microsoft-windows安装了32位版本的zeromq
>从https://github.com/paweljasinski/pyzmq/tree/ironpython-backend克隆ironpython-后端分支
>在pyzmq目录中,运行ipy.exe setup.py install –user
>从https://github.com/dotcloud/zerorpc-python克隆zerorpc
>在zerorpc-python中,运行ipy.exe setup.py install –user
>设置环境变量:设置PYZMQ_BACKEND = zmq.backend.ctypes
>尝试使用从https://github.com/dotcloud/zerorpc-python开始的’Cooler’类示例,并通过ipy.exe -X:Frames cooler.py运行
(cooler.py):
class Cooler(object):
""" Various convenience methods to make things cooler. """
def add_man(self, sentence):
""" End a sentence with ", man!" to make it sound cooler, and
return the result. """
return sentence + ", man!"
def add_42(self, n):
""" Add 42 to an integer argument to make it cooler, and return the
result. """
return n + 42
def boat(self, sentence):
""" Replace a sentence with "I'm on a boat!", and return that,
because it's cooler. """
return "I'm on a boat!"
import zerorpc
s = zerorpc.Server(Cooler())
s.bind("tcp://0.0.0.0:4242")
s.run()
现在,我看到此错误:
Traceback (most recent call last):
File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\select.py", line 26, in select_backend
File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\ctypes\__init__.py", line 26, in <module>
File "C:\Users\nlindop\AppData\Roaming\Python\IronPython27\site-packages\zmq\backend\ctypes\constants.py", line 16, in <module>
ImportError: No module named ZMQ
解决方法:
ZeroRPC似乎是纯python,基于pyzmq.在这种情况下,您可以尝试IronPython的pyzmq ctypes后端. https://github.com/paweljasinski/pyzmq/tree/ironpython-backend
>使用IronPython 2.7.5b2或更高版本
>从http://zeromq.org/distro:microsoft-windows安装32位版本的zmq
>安装pyzmq本身,然后克隆,而不是ipy.exe setup.py install –user.安装应检测到您的zmq并选择正确的dll
>激活ctypes后端,设置环境变量PYZMQ_BACKEND = zmq.backend.ctypes
更新:ZeroRPC依赖于gevent(在IronPython下不可用),因此以上说明仅对IronPython下的pyzmq有效