# 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](https://pypi.org/project/pemja)
```bash
pip install pemja
```
Java Maven Dependency
```
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>pemja</artifactId>
<version>{version}</version>
</dependency>
```
## Dependencies
- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)
## 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
```java
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
Raw data
{
"_id": null,
"home_page": "",
"name": "pemja",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "",
"author": "Apache Software Foundation",
"author_email": "hxbks2ks@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/90/2b/2ca14e70edd1c8bb38fcef6c6902d08702fa9a3a1e60da81b1a9cb22a200/pemja-0.4.1.tar.gz",
"platform": null,
"description": "# PemJa\n\n## What is it?\n\nPemJa is an open source cross language call framework based on FFI. It aims to provide a high-performance\n\nframework of calling between different languages.\n\n## Where to get it\n\nPython binary installers for the latest released version are available at the [Python package index](https://pypi.org/project/pemja)\n\n```bash\npip install pemja\n```\n\nJava Maven Dependency\n```\n<dependency>\n <groupId>com.alibaba</groupId>\n <artifactId>pemja</artifactId>\n <version>{version}</version>\n</dependency>\n```\n\n## Dependencies\n\n- [NumPy - Adds support for large, multi-dimensional arrays, matrices and high-level mathematical functions to operate on these arrays](https://www.numpy.org)\n\n## Installation from sources\n\nPrerequisites for building PemJa:\n\n* Unix-like environment (we use Linux, Mac OS X)\n* Git\n* Maven (we recommend version 3.2.5 and require at least 3.1.1)\n* Java 8 or 11 (Java 9 or 10 may work)\n* Python >= 3.8 (we recommend version 3.8, 3.9, 3.10, 3.11)\n\n```\ngit clone https://github.com/alibaba/pemja.git\ncd pemja\nmvn clean install -DskipTests\npip install -r dev/dev-requirements.txt\npython setup.py sdist\npip install dist/*.tar.gz\n```\n\n## Usage\n\n```java\nString path = ...;\nPythonInterpreterConfig config = PythonInterpreterConfig\n .newBuilder()\n .setPythonExec(\"python3\") // specify python exec\n .addPythonPaths(path) // add path to search path\n .build();\n\nPythonInterpreter interpreter = new PythonInterpreter(config);\n\n// set & get\ninterpreter.set(\"a\", 12345);\ninterpreter.get(\"a\"); // Object\ninterpreter.get(\"a\", Integer.class); // Integer\n\n// exec & eval\ninterpreter.exec(\"print(a)\");\n\n// invoke functions\ninterpreter.exec(\"import str_upper\");\nString result = interpreter.invoke(\"str_upper.upper\", \"abcd\");\n// Object invoke(String name, Object... args);\n// Object invoke(String name, Object[] args, Map<String, Object> kwargs);\n\n// invoke object methods\n/*\n// invoke.py\nclass A:\n def __init__(self):\n self._a = 0\n \n def get_value(self):\n return self._a\n \n def add(self, n):\n self._a += n\n \n def add_all(self, *args):\n for item in args:\n self._a += item\n return self._a\n \n def minus(self, n):\n self._a -= n\n return self._a\n*/\n\ninterpreter.exec(\"import invoke\");\ninterpreter.exec(\"a = invoke.A()\");\ninterpreter.invokeMethod(\"a\", \"add\", 3);\ninterpreter.invokeMethod(\"a\", \"minus\", 2);\ninterpreter.invokeMethod(\"a\", \"add_all\", 1, 2, 3);\n\n\n// python callback java methods\n/*\n// invoke_callback.py\nfrom pemja import findClass\n\nStringBuilder = findClass('java.lang.StringBuilder')\nInteger = findClass('java.lang.Integer')\n\ndef callback_java():\n sb = StringBuilder()\n sb.append('pemja')\n sb.append('java')\n sb.append('python')\n sb.append(Integer.toHexString(Integer.MAX_VALUE))\n return sb.toString()\n*/\ninterpreter.exec(\"import call_back\")\nprint(interpreter.invoke(\"call_back.callback_java\"))\n```\n\n## Documentation\n\n\n",
"bugtrack_url": null,
"license": "https://www.apache.org/licenses/LICENSE-2.0",
"summary": "PemJa",
"version": "0.4.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1b93fb4809517824ac4db195c07f50a2b1b3e15c2243b56c57cdbb0eeb67b635",
"md5": "7b6b887d8d4f6fd90f455cc471610d78",
"sha256": "04cdc97e64d5fcaef0ecccebd10ba9d6d933b8f897b8e52686e82af09d1fce5a"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "7b6b887d8d4f6fd90f455cc471610d78",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 52853,
"upload_time": "2023-10-12T08:45:33",
"upload_time_iso_8601": "2023-10-12T08:45:33.253330Z",
"url": "https://files.pythonhosted.org/packages/1b/93/fb4809517824ac4db195c07f50a2b1b3e15c2243b56c57cdbb0eeb67b635/pemja-0.4.1-cp310-cp310-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ea4f6797c2ab8e2e52d6e7532cdf4437fd64dc92fa2a571c3459610ae6b902a3",
"md5": "59585bbdb5620e458d28a61554738bce",
"sha256": "e743138539f3d2bd6835de8ad15bc5e2a5d8d26e3c4ecae230c814381c13efe1"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "59585bbdb5620e458d28a61554738bce",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 53423,
"upload_time": "2023-10-12T08:45:40",
"upload_time_iso_8601": "2023-10-12T08:45:40.961478Z",
"url": "https://files.pythonhosted.org/packages/ea/4f/6797c2ab8e2e52d6e7532cdf4437fd64dc92fa2a571c3459610ae6b902a3/pemja-0.4.1-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "dd334a4aebdbe7a86665e2073c019ec4e83546df528a802ab7114aad185a6432",
"md5": "06709b3f66695576bd342884fddfb2a1",
"sha256": "f6b07688bac56f7f21137010a372082f49a1bca5b19fee29774c29813714503a"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp310-cp310-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "06709b3f66695576bd342884fddfb2a1",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 64100,
"upload_time": "2023-10-12T08:45:48",
"upload_time_iso_8601": "2023-10-12T08:45:48.780233Z",
"url": "https://files.pythonhosted.org/packages/dd/33/4a4aebdbe7a86665e2073c019ec4e83546df528a802ab7114aad185a6432/pemja-0.4.1-cp310-cp310-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c27100185346edecf9bb12e652e9c78ec61bd9d1879c58f0afb6e34e3d21089a",
"md5": "ab2a78b99e19b139dfaade5f2c1cd701",
"sha256": "8b552ad0982f474eb40c5f9146a32aef1e2a0cf97341ab7620c91cd56cda3536"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "ab2a78b99e19b139dfaade5f2c1cd701",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 52809,
"upload_time": "2023-10-12T08:45:55",
"upload_time_iso_8601": "2023-10-12T08:45:55.784320Z",
"url": "https://files.pythonhosted.org/packages/c2/71/00185346edecf9bb12e652e9c78ec61bd9d1879c58f0afb6e34e3d21089a/pemja-0.4.1-cp311-cp311-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fb7001c8b19834b4620ce6a75288904a0a8717e6fecd3276ffc342448c0ea09a",
"md5": "1ebdf00bf63b0235ebebd7ec5b138767",
"sha256": "ec20f1038da8925f7720961cfc9f7c41a5194fb835fb0b2e71d8c9d0f496b524"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "1ebdf00bf63b0235ebebd7ec5b138767",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 53376,
"upload_time": "2023-10-12T08:46:02",
"upload_time_iso_8601": "2023-10-12T08:46:02.663462Z",
"url": "https://files.pythonhosted.org/packages/fb/70/01c8b19834b4620ce6a75288904a0a8717e6fecd3276ffc342448c0ea09a/pemja-0.4.1-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ac0818720708251bc2c3f1cf0128a8c66bb1113b6a024ead135f72350c148bec",
"md5": "6d22698e527dcd531ec7c11ccdbcd9d5",
"sha256": "78a4fa07bacc1b30b3acb88608e0622395cd8a34144dfe455ec8788e32fe3ca1"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp311-cp311-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "6d22698e527dcd531ec7c11ccdbcd9d5",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 63556,
"upload_time": "2023-10-12T08:46:09",
"upload_time_iso_8601": "2023-10-12T08:46:09.571014Z",
"url": "https://files.pythonhosted.org/packages/ac/08/18720708251bc2c3f1cf0128a8c66bb1113b6a024ead135f72350c148bec/pemja-0.4.1-cp311-cp311-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "adbcc39d692f3bdec9518b39ec80b22909970cf2d166eea048c2724c695b7b2f",
"md5": "3f121206edfd016ba1a012109f9b6a4e",
"sha256": "8a4c59145ac9ac23790213af7308e1266d6c127e6e83f6306f18cc95fad3999b"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "3f121206edfd016ba1a012109f9b6a4e",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 52768,
"upload_time": "2023-10-12T08:46:17",
"upload_time_iso_8601": "2023-10-12T08:46:17.903337Z",
"url": "https://files.pythonhosted.org/packages/ad/bc/c39d692f3bdec9518b39ec80b22909970cf2d166eea048c2724c695b7b2f/pemja-0.4.1-cp38-cp38-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9ccaddd877086d457bcca451518f1573af7974d9de6f0b067b5a0fb1c7896e72",
"md5": "d9ab623d5b936f4eddba56fe666180ad",
"sha256": "aca3917421e4fe7c862fc8d1b0d792f8e63da93020a4d2e45d895e6a530f2273"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp38-cp38-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "d9ab623d5b936f4eddba56fe666180ad",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 53384,
"upload_time": "2023-10-12T08:46:26",
"upload_time_iso_8601": "2023-10-12T08:46:26.579475Z",
"url": "https://files.pythonhosted.org/packages/9c/ca/ddd877086d457bcca451518f1573af7974d9de6f0b067b5a0fb1c7896e72/pemja-0.4.1-cp38-cp38-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "234c422c99d5d2b823309888714185dc4467a935a25fb1e265c604855d0ea4b9",
"md5": "6ffa5a1d95d54b2e64d5a3e61c2fb90b",
"sha256": "2f42e548c429c14a248698043e454fd4a85d4d8016130b798f1d84eec68b8754"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp38-cp38-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "6ffa5a1d95d54b2e64d5a3e61c2fb90b",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 325263,
"upload_time": "2023-10-12T08:46:36",
"upload_time_iso_8601": "2023-10-12T08:46:36.011472Z",
"url": "https://files.pythonhosted.org/packages/23/4c/422c99d5d2b823309888714185dc4467a935a25fb1e265c604855d0ea4b9/pemja-0.4.1-cp38-cp38-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5d1e2ce8975be4fdd4113c079959260ca615f913ced4889b3fdc5303934b525b",
"md5": "6b528b9ae19fa2981122331a0598507e",
"sha256": "20d8d508d192f5f91a98b74f922f29c5ea46e4f8e3ae019123a82172f2bdba02"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "6b528b9ae19fa2981122331a0598507e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 52866,
"upload_time": "2023-10-12T08:46:43",
"upload_time_iso_8601": "2023-10-12T08:46:43.726517Z",
"url": "https://files.pythonhosted.org/packages/5d/1e/2ce8975be4fdd4113c079959260ca615f913ced4889b3fdc5303934b525b/pemja-0.4.1-cp39-cp39-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0992d560dfb62f96763bb1671113ae918abd1a7ec5708b59984a71620a8a20c0",
"md5": "29c367f691ba4336b20213128a601cb7",
"sha256": "57f0eac19e352c1ada6f8c2d0c4a497615049f0bd847dabb25c6f0a5a6ffed75"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp39-cp39-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "29c367f691ba4336b20213128a601cb7",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 53452,
"upload_time": "2023-10-12T08:46:51",
"upload_time_iso_8601": "2023-10-12T08:46:51.300321Z",
"url": "https://files.pythonhosted.org/packages/09/92/d560dfb62f96763bb1671113ae918abd1a7ec5708b59984a71620a8a20c0/pemja-0.4.1-cp39-cp39-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "93c1d6200da3e2f8a631ab8fd549371c42447ebdf2e256b1a50c0d8285918898",
"md5": "c76f2ae368654b578130302e081be176",
"sha256": "aac7c6c7301d06b48988710a664ca64d1d6fada0f8d1e7db7e6f5d320d65d6b0"
},
"downloads": -1,
"filename": "pemja-0.4.1-cp39-cp39-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "c76f2ae368654b578130302e081be176",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 64100,
"upload_time": "2023-10-12T08:46:59",
"upload_time_iso_8601": "2023-10-12T08:46:59.634887Z",
"url": "https://files.pythonhosted.org/packages/93/c1/d6200da3e2f8a631ab8fd549371c42447ebdf2e256b1a50c0d8285918898/pemja-0.4.1-cp39-cp39-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "902b2ca14e70edd1c8bb38fcef6c6902d08702fa9a3a1e60da81b1a9cb22a200",
"md5": "47cc0b9b8d3a85e7c9c9a0e104c074fd",
"sha256": "38b0466ba48822cd9fa65bf8465c45474bf3f048d6458388e0bf895904258e8c"
},
"downloads": -1,
"filename": "pemja-0.4.1.tar.gz",
"has_sig": false,
"md5_digest": "47cc0b9b8d3a85e7c9c9a0e104c074fd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 50674,
"upload_time": "2023-10-12T08:47:06",
"upload_time_iso_8601": "2023-10-12T08:47:06.778433Z",
"url": "https://files.pythonhosted.org/packages/90/2b/2ca14e70edd1c8bb38fcef6c6902d08702fa9a3a1e60da81b1a9cb22a200/pemja-0.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-12 08:47:06",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pemja"
}