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.8 (we recommend version 3.8, 3.9, 3.10, 3.11)
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", Integer.class); // Integer
// 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);
// python callback java methods
/*
// invoke_callback.py
from pemja import findClass
StringBuilder = findClass('java.lang.StringBuilder')
Integer = findClass('java.lang.Integer')
def callback_java():
sb = StringBuilder()
sb.append('pemja')
sb.append('java')
sb.append('python')
sb.append(Integer.toHexString(Integer.MAX_VALUE))
return sb.toString()
*/
interpreter.exec("import call_back")
print(interpreter.invoke("call_back.callback_java"))
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
Built Distributions
File details
Details for the file pemja-0.4.1.tar.gz
.
File metadata
- Download URL: pemja-0.4.1.tar.gz
- Upload date:
- Size: 50.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38b0466ba48822cd9fa65bf8465c45474bf3f048d6458388e0bf895904258e8c |
|
MD5 | 47cc0b9b8d3a85e7c9c9a0e104c074fd |
|
BLAKE2b-256 | 902b2ca14e70edd1c8bb38fcef6c6902d08702fa9a3a1e60da81b1a9cb22a200 |
File details
Details for the file pemja-0.4.1-cp311-cp311-manylinux1_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp311-cp311-manylinux1_x86_64.whl
- Upload date:
- Size: 63.6 kB
- Tags: CPython 3.11
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78a4fa07bacc1b30b3acb88608e0622395cd8a34144dfe455ec8788e32fe3ca1 |
|
MD5 | 6d22698e527dcd531ec7c11ccdbcd9d5 |
|
BLAKE2b-256 | ac0818720708251bc2c3f1cf0128a8c66bb1113b6a024ead135f72350c148bec |
File details
Details for the file pemja-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 53.4 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec20f1038da8925f7720961cfc9f7c41a5194fb835fb0b2e71d8c9d0f496b524 |
|
MD5 | 1ebdf00bf63b0235ebebd7ec5b138767 |
|
BLAKE2b-256 | fb7001c8b19834b4620ce6a75288904a0a8717e6fecd3276ffc342448c0ea09a |
File details
Details for the file pemja-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 52.8 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b552ad0982f474eb40c5f9146a32aef1e2a0cf97341ab7620c91cd56cda3536 |
|
MD5 | ab2a78b99e19b139dfaade5f2c1cd701 |
|
BLAKE2b-256 | c27100185346edecf9bb12e652e9c78ec61bd9d1879c58f0afb6e34e3d21089a |
File details
Details for the file pemja-0.4.1-cp310-cp310-manylinux1_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp310-cp310-manylinux1_x86_64.whl
- Upload date:
- Size: 64.1 kB
- Tags: CPython 3.10
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b07688bac56f7f21137010a372082f49a1bca5b19fee29774c29813714503a |
|
MD5 | 06709b3f66695576bd342884fddfb2a1 |
|
BLAKE2b-256 | dd334a4aebdbe7a86665e2073c019ec4e83546df528a802ab7114aad185a6432 |
File details
Details for the file pemja-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 53.4 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e743138539f3d2bd6835de8ad15bc5e2a5d8d26e3c4ecae230c814381c13efe1 |
|
MD5 | 59585bbdb5620e458d28a61554738bce |
|
BLAKE2b-256 | ea4f6797c2ab8e2e52d6e7532cdf4437fd64dc92fa2a571c3459610ae6b902a3 |
File details
Details for the file pemja-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 52.9 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04cdc97e64d5fcaef0ecccebd10ba9d6d933b8f897b8e52686e82af09d1fce5a |
|
MD5 | 7b6b887d8d4f6fd90f455cc471610d78 |
|
BLAKE2b-256 | 1b93fb4809517824ac4db195c07f50a2b1b3e15c2243b56c57cdbb0eeb67b635 |
File details
Details for the file pemja-0.4.1-cp39-cp39-manylinux1_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp39-cp39-manylinux1_x86_64.whl
- Upload date:
- Size: 64.1 kB
- Tags: CPython 3.9
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aac7c6c7301d06b48988710a664ca64d1d6fada0f8d1e7db7e6f5d320d65d6b0 |
|
MD5 | c76f2ae368654b578130302e081be176 |
|
BLAKE2b-256 | 93c1d6200da3e2f8a631ab8fd549371c42447ebdf2e256b1a50c0d8285918898 |
File details
Details for the file pemja-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 53.5 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57f0eac19e352c1ada6f8c2d0c4a497615049f0bd847dabb25c6f0a5a6ffed75 |
|
MD5 | 29c367f691ba4336b20213128a601cb7 |
|
BLAKE2b-256 | 0992d560dfb62f96763bb1671113ae918abd1a7ec5708b59984a71620a8a20c0 |
File details
Details for the file pemja-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 52.9 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20d8d508d192f5f91a98b74f922f29c5ea46e4f8e3ae019123a82172f2bdba02 |
|
MD5 | 6b528b9ae19fa2981122331a0598507e |
|
BLAKE2b-256 | 5d1e2ce8975be4fdd4113c079959260ca615f913ced4889b3fdc5303934b525b |
File details
Details for the file pemja-0.4.1-cp38-cp38-manylinux1_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp38-cp38-manylinux1_x86_64.whl
- Upload date:
- Size: 325.3 kB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f42e548c429c14a248698043e454fd4a85d4d8016130b798f1d84eec68b8754 |
|
MD5 | 6ffa5a1d95d54b2e64d5a3e61c2fb90b |
|
BLAKE2b-256 | 234c422c99d5d2b823309888714185dc4467a935a25fb1e265c604855d0ea4b9 |
File details
Details for the file pemja-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 53.4 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | aca3917421e4fe7c862fc8d1b0d792f8e63da93020a4d2e45d895e6a530f2273 |
|
MD5 | d9ab623d5b936f4eddba56fe666180ad |
|
BLAKE2b-256 | 9ccaddd877086d457bcca451518f1573af7974d9de6f0b067b5a0fb1c7896e72 |
File details
Details for the file pemja-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: pemja-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl
- Upload date:
- Size: 52.8 kB
- Tags: CPython 3.8, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a4c59145ac9ac23790213af7308e1266d6c127e6e83f6306f18cc95fad3999b |
|
MD5 | 3f121206edfd016ba1a012109f9b6a4e |
|
BLAKE2b-256 | adbcc39d692f3bdec9518b39ec80b22909970cf2d166eea048c2724c695b7b2f |