PemJa
Project description
PemJa
What is it?
PemJa is an open source cross language call framework based on FFI. It aims to provide a high-performance
framework of calling between different languages.
Where to get it
Python binary installers for the latest released version are available at the Python package index
pip install pemja
Java Maven Dependency
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>pemja</artifactId>
<version>{version}</version>
</dependency>
Dependencies
Installation from sources
Prerequisites for building PemJa:
- Unix-like environment (we use Linux, Mac OS X)
- Git
- Maven (we recommend version 3.2.5 and require at least 3.1.1)
- Java 8 or 11 (Java 9 or 10 may work)
- Python >= 3.7 (we recommend version 3.7, 3.8, 3.9)
git clone https://github.com/alibaba/pemja.git
cd pemja
mvn clean install -DskipTests
pip install -r dev/dev-requirements.txt
python setup.py sdist
pip install dist/*.tar.gz
Usage
String path = ...;
PythonInterpreterConfig config = PythonInterpreterConfig
.newBuilder()
.setPythonExec("python3") // specify python exec
.addPythonPaths(path) // add path to search path
.build();
PythonInterpreter interpreter = new PythonInterpreter(config);
// set & get
interpreter.set("a", 12345);
interpreter.get("a"); // Object
interpreter.get("a", int.class); // int
// exec & eval
interpreter.exec("print(a)");
// invoke functions
interpreter.exec("import str_upper");
String result = interpreter.invoke("str_upper.upper", "abcd");
// Object invoke(String name, Object... args);
// Object invoke(String name, Object[] args, Map<String, Object> kwargs);
// invoke object methods
/*
// invoke.py
class A:
def __init__(self):
self._a = 0
def get_value(self):
return self._a
def add(self, n):
self._a += n
def add_all(self, *args):
for item in args:
self._a += item
return self._a
def minus(self, n):
self._a -= n
return self._a
*/
interpreter.exec("import invoke");
interpreter.exec("a = invoke.A()");
interpreter.invokeMethod("a", "add", 3);
interpreter.invokeMethod("a", "minus", 2);
interpreter.invokeMethod("a", "add_all", 1, 2, 3);
Documentation
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pemja-0.1.6.tar.gz
(33.1 kB
view hashes)
Built Distributions
Close
Hashes for pemja-0.1.6-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 433fe00a41a984414d51d8df7bbfbdbdfcaa238a44efc409033c2bb664180f79 |
|
MD5 | 62e5bf02acadf343d4e4429e09499968 |
|
BLAKE2b-256 | 43e2e24254dd70e81648d6ff91e86323e67e7ac608ef8c6a4fd6b0386f94a2a6 |
Close
Hashes for pemja-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 037b3723d2b95b1001cc779e0a4ce354096d86daf0017525188566b967bcf709 |
|
MD5 | f46ac42225eb505b07f859f860f57eae |
|
BLAKE2b-256 | 3843a90f6d7b5a25f18e458949c36fea0ec61b9b7583c244dcbb0ba41a1da548 |
Close
Hashes for pemja-0.1.6-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00508df618ab8dd391745d8bddb94161c8849d35ddd4fae2a5bbc9a92d5eaae6 |
|
MD5 | 5ba7f381c90c3365991f742d91d332a0 |
|
BLAKE2b-256 | 6e6f823a0dff1cb9cf61c181e599084f9fb1653e77384c632462d2780f36348e |
Close
Hashes for pemja-0.1.6-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dccd2e81754919559d7afb0bdcd81c141511af0c5836c330b60b9a3c19a1d8ae |
|
MD5 | fef55f6a2b24309173888af91bd549a2 |
|
BLAKE2b-256 | e547eef932103d022a32cdc517ffd43398b7697adfbaeeb6206d51026cefd240 |
Close
Hashes for pemja-0.1.6-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e374f7381b005048f65e5a92d4c1a3b885f23fbd8e36932f3496ac28035be5 |
|
MD5 | d828e03f1fbd55ac0f2f5282e86ee3c4 |
|
BLAKE2b-256 | 113d0ad77cc426f522ee50f3fa01164dc1371317374aad22919769964bbfeaf2 |
Close
Hashes for pemja-0.1.6-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0ff6c0ae1af876ef51ecc4102d6c82121a4b2fe0a3f5a726c6ac2f075259f4a |
|
MD5 | e15ff8d0859d601a4daec78a88e9795e |
|
BLAKE2b-256 | d03f1763813fdb564fdb2fe6bcf7250b7dc887e06309dae8c9e78955d61a2fd8 |
Close
Hashes for pemja-0.1.6-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a92a9a4b2bf206f982b9ba86003df1ca753614312b866fa262a1b88953dec36f |
|
MD5 | 3e3bac828cb371a204a85fc6eb4048f7 |
|
BLAKE2b-256 | 1ecd3354654a219c32a079d7b116517fe65acb437b7e956b94e8ee3bb9474d8d |
Close
Hashes for pemja-0.1.6-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c84950b81d59aaad84b59f9d79a2a8e93d0d45cc324e2d0517a25bf41ec417f |
|
MD5 | fa41b4ca8f58d5a209462858c0699ea9 |
|
BLAKE2b-256 | 0020020035f4a71ac69a34fa610098fc0d5467bb67ab566baf064e9d5acc785d |