Skip to main content

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);


// 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


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.2.4.tar.gz (48.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pemja-0.2.4-cp39-cp39-manylinux1_x86_64.whl (64.0 kB view details)

Uploaded CPython 3.9

pemja-0.2.4-cp39-cp39-macosx_11_0_arm64.whl (52.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

pemja-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl (52.2 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

pemja-0.2.4-cp38-cp38-manylinux1_x86_64.whl (324.5 kB view details)

Uploaded CPython 3.8

pemja-0.2.4-cp38-cp38-macosx_11_0_arm64.whl (52.7 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

pemja-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl (52.1 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

pemja-0.2.4-cp37-cp37m-manylinux1_x86_64.whl (319.3 kB view details)

Uploaded CPython 3.7m

pemja-0.2.4-cp37-cp37m-macosx_10_9_x86_64.whl (52.0 kB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

Details for the file pemja-0.2.4.tar.gz.

File metadata

  • Download URL: pemja-0.2.4.tar.gz
  • Upload date:
  • Size: 48.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4.tar.gz
Algorithm Hash digest
SHA256 c3a7938668bb308b4481718b30783cd8c012514a7bd251971cfb596a3719a23a
MD5 7215e21fe47a24560cd70d88a8c793a7
BLAKE2b-256 ff6858105f37fd5da1b01108d2bcfba97efa2e5508abe0d6ba2b34b0e0d523e0

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp39-cp39-manylinux1_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp39-cp39-manylinux1_x86_64.whl
  • Upload date:
  • Size: 64.0 kB
  • Tags: CPython 3.9
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp39-cp39-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c7ea252b723fb483da6697442e0dfba30b9a4a82de590ca5ed39a8774ade29ad
MD5 aac20439679b80a61758d5f6fea00dce
BLAKE2b-256 5dbbd47b422f0d66f04a030288d26049324ad4cccde6dd71c765d2fbad3f596f

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 52.8 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d1248b98c4513bc94c948f4f08f003f75517be801c4b18ee0ac9b79529f92cbe
MD5 b2fc7dd989c73a19e7a799e4075d9c86
BLAKE2b-256 e2c62bc6b7abee44be15908112715e0c14eda120fea1a21440d8ba664786701d

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 52.2 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 971485e1c52e1ae73a376f900f280c9d14dea33fa09077419cd259788b09a1de
MD5 7c4c33ea34db9612b13abfa3b09c513a
BLAKE2b-256 569af60b8362903c08dc069bedeeab7d214449b9e8ab14e8f20983270c78c787

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 324.5 kB
  • Tags: CPython 3.8
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9c92e6d5c21db8546afe14279d4bb149899271447201a7c73ac9f6ed30478ee3
MD5 2deb71f90faa1760f5a753c56dfbde87
BLAKE2b-256 e5b9766debaaab21d442aef8b677483c13a53ea0d716628c02e5a95d62a664d9

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 52.7 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 965c75fc2e5340ba17e3c416684efff715a6a2f81a346b4d024866ce2f0cead9
MD5 8e6467acb233369dce10f4cbae07f530
BLAKE2b-256 17b5c3a7ada59ef52c6abcaa96360af6492a7cb4eb2212a0d754164066b70dd5

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 52.1 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 98df4a38f29c7bc0b749c85908ac1d692a8e0f5eeafba011b750dd388d749d7e
MD5 4ffc045ef7df09a56e321720aa6f0a38
BLAKE2b-256 bd3eadd31a2db0d8797469a0a7311cbbbd5ef3c1b593a079e9911fb21714afbc

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 319.3 kB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 39b64a70facc00e04d3adbbe484bf2ff531547ba1b9f99cc0ce2b1329ad60590
MD5 77344be3db8bb3957e9cd9b12608f8bb
BLAKE2b-256 660d74ed67d2e9299ae3a6ff6fd03aa0fa8f408dcfde1f961abd93fb3ee0e968

See more details on using hashes here.

File details

Details for the file pemja-0.2.4-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: pemja-0.2.4-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 52.0 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.26.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pemja-0.2.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3d95d68697891343dead38147092d44f80ea0f52caf60017921a77c7c1bc3715
MD5 378e632cff33c459803cdd4107fff0b8
BLAKE2b-256 79b20d7f3a2cc64f5452421d6b736e4c1909457003f15f1e69597687ad2dd97f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page