Does IronPython implement python standard library?

吃可爱长大的小学妹 提交于 2019-12-07 02:26:50

问题


I tried IronPython some time ago and it seemed that it implements only python language, and uses .NET for libraries. Is this still the case? Can one use python modules from IronPython?


回答1:


The IronPython installer includes the Python standard library. Otherwise, you can use the standard library from a compatible Python install (IPy 2.0 -> CPy 2.5, IPy 2.6 -> CPy 2.6). Either copy the Python Lib directory to the IronPython folder, or set IRONPYTHONPATH.

Do note that only the pure Pyton modules will be available; Python modules that require C extensions have to be re-implemented (and most of them have been).




回答2:


You can use the Python standard library from IronPython just fine. Here's how:

  1. Install Python.
  2. Setup an environment variable named IRONPYTHONPATH that points to the standard library directory.

Next time ipy.exe is run, site.py is read and you're good to go.




回答3:


The .msi installer for IronPython includes all parts of the CPython standard library that should work with IronPython. You can simply copy the standard library from a CPython install if you prefer, although you're better off getting just the modules that the IronPython developers have ensured with with IronPython - this is most of them.

Modules that are implemented using the CPython C API ('extension modules') will not be available. IronClad is an open-source project that aims to let you seamlessly use these modules - it's not perfect yet, but (e.g.) most of the NumPy tests pass.

The other option for these 'extension modules' is to replace them with a pure-Python version (e.g. from PyPy) or with a wrapper over a .NET class. The IronPython Community Edition is an IronPython distribution that includes such wrappers for many modules that are not included in the standard IronPython distribution.




回答4:


(As I said here:)

I've not used it myself, but you may get some mileage out of Ironclad - it supposedly lets you use CPython from IronPython...



来源:https://stackoverflow.com/questions/1296640/does-ironpython-implement-python-standard-library

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!