# 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": null,
"name": "pemja",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "Apache Software Foundation",
"author_email": "hxbks2ks@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/37/07/ef4921eb377f49dd9195042fa30864319da5edbb057c4213a5729910eaae/pemja-0.4.2.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.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3949e6f009af0611ec8d971bd480cf4c0f6f5da80a91be36c8c75dc67d718f8c",
"md5": "be2603a7966699c8cad0bd8ffef307a8",
"sha256": "ec2b177516bf158ae8afc13961bda508107e44b2f04ffa6411e6e85dacdabf5b"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp310-cp310-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "be2603a7966699c8cad0bd8ffef307a8",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 50151,
"upload_time": "2025-01-09T05:08:04",
"upload_time_iso_8601": "2025-01-09T05:08:04.744414Z",
"url": "https://files.pythonhosted.org/packages/39/49/e6f009af0611ec8d971bd480cf4c0f6f5da80a91be36c8c75dc67d718f8c/pemja-0.4.2-cp310-cp310-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4fd731e7a6c152cb602643ea728c79a33e432c0b58d42ea8b55f1a3cbc722608",
"md5": "73c4514e4313690d182dfc6734ee3823",
"sha256": "3b43ef9088bc99127fbbe3094dc2db36d60341e25f8a5ace144a9929fdd34041"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp310-cp310-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "73c4514e4313690d182dfc6734ee3823",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 51606,
"upload_time": "2025-01-09T05:08:07",
"upload_time_iso_8601": "2025-01-09T05:08:07.223430Z",
"url": "https://files.pythonhosted.org/packages/4f/d7/31e7a6c152cb602643ea728c79a33e432c0b58d42ea8b55f1a3cbc722608/pemja-0.4.2-cp310-cp310-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8482d8efb61a5a4558b8850293d19813f07a4cbf9c6f0fa7b666e8f4270db15e",
"md5": "864fc5267dd69a1ca8adca75de020ad2",
"sha256": "c191aa36818430aa06fe13164c0c5f877e7f1a9a09cab6dbe8caee42367fa5dc"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp310-cp310-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "864fc5267dd69a1ca8adca75de020ad2",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 64414,
"upload_time": "2025-01-09T05:08:09",
"upload_time_iso_8601": "2025-01-09T05:08:09.990742Z",
"url": "https://files.pythonhosted.org/packages/84/82/d8efb61a5a4558b8850293d19813f07a4cbf9c6f0fa7b666e8f4270db15e/pemja-0.4.2-cp310-cp310-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cf0369c049af008b1cf7d2be0e012060e21ca717eff88d1fbc139ffdda7ca9ac",
"md5": "cc87fd649581c03a6ea44fc75fdea9c7",
"sha256": "fcbc4fb92693876c046041751d6fa6f426196d3a5765a84027d5852e4c880894"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp311-cp311-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "cc87fd649581c03a6ea44fc75fdea9c7",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 50028,
"upload_time": "2025-01-09T05:08:12",
"upload_time_iso_8601": "2025-01-09T05:08:12.539824Z",
"url": "https://files.pythonhosted.org/packages/cf/03/69c049af008b1cf7d2be0e012060e21ca717eff88d1fbc139ffdda7ca9ac/pemja-0.4.2-cp311-cp311-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1aa5f175e35de621724ff5845ae488c7ec189e42e6951f8572b30e347b3ca757",
"md5": "5825bcf3f1c4c54290ec92854efcb692",
"sha256": "d36a272c0647a630049317e076f64a2e90887d3b3d24ebf2494391a15f15b185"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "5825bcf3f1c4c54290ec92854efcb692",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 51445,
"upload_time": "2025-01-09T05:08:14",
"upload_time_iso_8601": "2025-01-09T05:08:14.796315Z",
"url": "https://files.pythonhosted.org/packages/1a/a5/f175e35de621724ff5845ae488c7ec189e42e6951f8572b30e347b3ca757/pemja-0.4.2-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1e63b56e14fb1745ae9cd24a71c16656295cc415d52529840ac3b33ccd714581",
"md5": "bb76da61d2a01fd517f1aa3b18d1c913",
"sha256": "5f7fa97b221a49456c0952d5ecc9b9b46ef5a3b9d7e79a5472a244933ab98bcf"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp311-cp311-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "bb76da61d2a01fd517f1aa3b18d1c913",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 63815,
"upload_time": "2025-01-09T05:08:15",
"upload_time_iso_8601": "2025-01-09T05:08:15.942985Z",
"url": "https://files.pythonhosted.org/packages/1e/63/b56e14fb1745ae9cd24a71c16656295cc415d52529840ac3b33ccd714581/pemja-0.4.2-cp311-cp311-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce00d873668c418557245d658cc147fa99c9addbb996b9d730481586080d2c36",
"md5": "1a0bb3f8744cffdfc1faadefb8fcc773",
"sha256": "43e0fa68ba2dc1c72e754aec521109fad0668a40757f8fab2488f4f57076547f"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp38-cp38-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "1a0bb3f8744cffdfc1faadefb8fcc773",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 50033,
"upload_time": "2025-01-09T05:08:20",
"upload_time_iso_8601": "2025-01-09T05:08:20.849094Z",
"url": "https://files.pythonhosted.org/packages/ce/00/d873668c418557245d658cc147fa99c9addbb996b9d730481586080d2c36/pemja-0.4.2-cp38-cp38-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f37677abedf66cad2c0190c7cabc2293d8bd82e1fbda88783e82627be1291558",
"md5": "9562d3e59648d45f3bcbfd4ce598528e",
"sha256": "2be687b4933fc502a553e37356aa6984e13f847e1d427e8f02abae84a42dc8c9"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp38-cp38-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "9562d3e59648d45f3bcbfd4ce598528e",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 51498,
"upload_time": "2025-01-09T05:08:23",
"upload_time_iso_8601": "2025-01-09T05:08:23.674736Z",
"url": "https://files.pythonhosted.org/packages/f3/76/77abedf66cad2c0190c7cabc2293d8bd82e1fbda88783e82627be1291558/pemja-0.4.2-cp38-cp38-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b45a145cec43a61f1768cdaab583fe29ae50befc2f6f95862d6af5da6ae13f6c",
"md5": "a07f07e3718c2ca158b379b4e1cd1d91",
"sha256": "e6ee2c8b61f7e8445de3d4f0aaa25629ee690539837395a1a96570faf84f6838"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp38-cp38-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "a07f07e3718c2ca158b379b4e1cd1d91",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 325960,
"upload_time": "2025-01-09T05:08:25",
"upload_time_iso_8601": "2025-01-09T05:08:25.889016Z",
"url": "https://files.pythonhosted.org/packages/b4/5a/145cec43a61f1768cdaab583fe29ae50befc2f6f95862d6af5da6ae13f6c/pemja-0.4.2-cp38-cp38-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "12e72fab198173a940770af2de9e45828c9916b8bd212cd886fcccd04f090878",
"md5": "624db7fd3d15fc62175891d0fdd5f719",
"sha256": "4941201cb2936390402ecd9f251990a3d48ffdce74b5fd69569dc2fc66476723"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp39-cp39-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "624db7fd3d15fc62175891d0fdd5f719",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 50163,
"upload_time": "2025-01-09T05:08:27",
"upload_time_iso_8601": "2025-01-09T05:08:27.276060Z",
"url": "https://files.pythonhosted.org/packages/12/e7/2fab198173a940770af2de9e45828c9916b8bd212cd886fcccd04f090878/pemja-0.4.2-cp39-cp39-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "604834364a0dcae3597ff276a08bec5e203da5753cd649bcb9ee014a51bc15c6",
"md5": "b58eb0572b70c4473fb758f42c73347f",
"sha256": "0e98c6d055336e852662cf5dcbf5f3311d0fa264c5b8b2417686559974417957"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp39-cp39-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "b58eb0572b70c4473fb758f42c73347f",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 51636,
"upload_time": "2025-01-09T05:08:30",
"upload_time_iso_8601": "2025-01-09T05:08:30.859581Z",
"url": "https://files.pythonhosted.org/packages/60/48/34364a0dcae3597ff276a08bec5e203da5753cd649bcb9ee014a51bc15c6/pemja-0.4.2-cp39-cp39-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f815701416b7aefc790122345c127789fdce522fa470795e51658152d78d5753",
"md5": "f84b2a175d40759607fcab016c2e6e7e",
"sha256": "31c37730ee6af0c1131b46423e826e3af3088de876a4e186a0805ccfc3f39b16"
},
"downloads": -1,
"filename": "pemja-0.4.2-cp39-cp39-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "f84b2a175d40759607fcab016c2e6e7e",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 64423,
"upload_time": "2025-01-09T05:08:32",
"upload_time_iso_8601": "2025-01-09T05:08:32.036144Z",
"url": "https://files.pythonhosted.org/packages/f8/15/701416b7aefc790122345c127789fdce522fa470795e51658152d78d5753/pemja-0.4.2-cp39-cp39-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3707ef4921eb377f49dd9195042fa30864319da5edbb057c4213a5729910eaae",
"md5": "a074c90b168fda63d7fbea6f9370adca",
"sha256": "e9470abc02da2dd606ad4033d6f1f275b85b5f5ab4b965af9a738dbed9edef9a"
},
"downloads": -1,
"filename": "pemja-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "a074c90b168fda63d7fbea6f9370adca",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 50787,
"upload_time": "2025-01-09T05:08:34",
"upload_time_iso_8601": "2025-01-09T05:08:34.898274Z",
"url": "https://files.pythonhosted.org/packages/37/07/ef4921eb377f49dd9195042fa30864319da5edbb057c4213a5729910eaae/pemja-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-09 05:08:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pemja"
}