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.5.tar.gz
(32.9 kB
view hashes)
Built Distributions
Close
Hashes for pemja-0.1.5-cp39-cp39-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3236eee6b4519b574b4b6904117287ed4c87c034961284b4a4b636151ca375ce |
|
MD5 | be3f82fb56e47a6853f05eecd1d73022 |
|
BLAKE2b-256 | ce0fb6e20b989f66bfd13679b39fa7deb527606835a822ec0c963b7bb4e88e51 |
Close
Hashes for pemja-0.1.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04f3b09abf6d7d12d80943db3f458770e74991f05f85ea2474d802bd23cc4abe |
|
MD5 | 4e710873b42488042435ba89a15079e0 |
|
BLAKE2b-256 | 89a6861076bd5411e4472d7fdc758c19aa4b788f6ee28954c6022228121935f0 |
Close
Hashes for pemja-0.1.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 672c78dc29ffea71755701c90606922fee25e9432ea3c9138ab84032c3d90704 |
|
MD5 | 56ced1f2b7b52ca19242a02c151c2abb |
|
BLAKE2b-256 | 9680f13176c34822586ca897dd71e352a8cd21a3f019376a2164eeb1bb4b64f4 |
Close
Hashes for pemja-0.1.5-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c9576b2fba265e62b5eb218a63debd9400e0d851c5e94f1e25acfcd895f0676 |
|
MD5 | 8979ecf1d071ece88bd001cb5e8d1150 |
|
BLAKE2b-256 | 595705fe87bc8c9a9506093d292eb41fe9a4583799ba9e52e32244af843d01d8 |
Close
Hashes for pemja-0.1.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f11650f4d1a4cbabef82d1e33ea62565bff17dcdc3801d63d8b5e735b8fb5fe7 |
|
MD5 | f3bc92806ffc1208bf1b1879d8e4d50c |
|
BLAKE2b-256 | 5628afa05521fed83924eaa470621348bfabf09d5f41049e4f547b899a4d494e |
Close
Hashes for pemja-0.1.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eb1f61121a34466e8c8ad1484b4312ad69b1d762373152589ed289b78734e6e |
|
MD5 | ea040ce49495402eb71f804b91bfee4c |
|
BLAKE2b-256 | 8db66913d2ec221be349511a8d07681b80abecc09c1a660f0b9f90972d81f3ac |
Close
Hashes for pemja-0.1.5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4acf4439771e324c32f5decef53eec2616318607e1f887df970dd2785e1ac83a |
|
MD5 | 49c13eb99d8142d9a27b1031ca1774eb |
|
BLAKE2b-256 | a5d234dd614a5b4eb1b0ff84d62929da53d52e6fb225c3c14c1e69b5407f40a9 |
Close
Hashes for pemja-0.1.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 492e912575b236442cdfa71c6e5a14be4609815c54c53cd3a83c125e75b659a2 |
|
MD5 | 5ec90402e6627eb0ac8adddf0a776083 |
|
BLAKE2b-256 | 2d7925d48c210b15aa06c68bc9f48ada47fc616d29a0097364f36cae3e1cabd4 |