允许Python动态访问任意Java对象(基于CyTys/CFFI的PY4J)
jtypes.py4j的Python项目详细描述
当前仅作为占位符(因为基本包jtypes.jvm仍在开发中)
j类型.py4j
使python能够动态访问任意java对象。
概述
jtypes.py4j enables Python programs to dynamically access arbitrary Java objects via Java’s Native Invocation Interface (JNI).
jtypes.py4j is a lightweight Python package, based on the ctypes or cffi library.It is an almost fully compliant implementation of Barthelemy Dagenais’s Py4J package by reimplementing its functionality in a clean Python via JNI instead of Python and Java via custom API service.
关于PY4J:
Py4J enables Python programs running in a Python interpreter to dynamically access Java objects in a Java Virtual Machine. Methods are called as if the Java objects resided in the Python interpreter and Java collections can be accessed through standard Python collection methods. Py4J also enables Java programs to call back Python objects.
Here is a brief example of what you can do with Py4J.The following Python program creates a java.util.Random instance from a JVM and calls some of its methods.>>>frompy4j.java_gatewayimportJavaGateway>>>gateway=JavaGateway()# connect to the JVM>>>random=gateway.jvm.java.util.Random()# create a java.util.Random instance>>>number1=random.nextInt(10)# call the Random.nextInt method>>>number2=random.nextInt(10)>>>print(number1,number2)(2,7)
要求
- Java运行时(JRE)或Java开发工具包(JDK)和numpy。
安装
先决条件:
- python 2.7或更高版本或3.4或更高版本
- http://www.python.org/
- 2.7和3.6是主要的测试环境。
- pip和setuptools
要安装,请运行:
python -m pip install --upgrade jtypes.py4j
为了确保一切正常运行,您可以使用:
python -m jt.py4j.tests
开发
从源安装:
克隆sources并运行:
python -m pip install ./jtypes.py4j
或开发模式:
python -m pip install --editable ./jtypes.py4j
先决条件:
开发严格基于tox。要安装它,请运行:
python -m pip install tox
许可证
Copyright (c) 2015-2018, Adam KarpierzLicensed under the BSD licensePlease refer to the accompanying LICENSE file.
更改日志
0.10.8a1(2018-11-08)
- 与PY4J主分支同步(V.0.10.8)。
- 更新所需的setuptools版本。
- 小的设置和测试改进。
0.10.7a2(2018-09-14)
- 与PY4J主分支同步(V.0.10.7)。
0.10.7a1(2018-06-15)
- 与PY4J主分支同步(V.0.10.7)。
0.10.6a4(2018-05-22)
- 更新所需的setuptools版本。
0.10.6a3(2018-02-26)
- 改进和简化安装和包装。
0.10.6a2(2018-01-29)
- 开发转移到github。
- 版本号同步。使用原装PY4J。
0.0.1a1(2017-01-10)
- 第一次阿尔法释放。
0.0.1a0(2015-08-05)
- 初始版本。