ninia / jep

Embed Python in Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jep in android

huazai023 opened this issue · comments

When I use android ndk to compile jep, it prompts that libjvm.so cannot be found, what library to use in Android to replace libjvm.so

I have enabled Jep to run on Android. Can I propose a pull request

Can I propose a pull request

That would be fantastic.

Here's how to get jep running on Android:

  1. Modify the jep setup.py file. The content of the modified patch file is as follows:
--- a/setup.py	2023-06-28 03:18:14.651024222 +0000
+++ b/setup.py	2023-06-28 03:18:04.786364976 +0000
@@ -73,7 +73,7 @@
         defines.append(('WIN32', 1))
         #Disable warnings about Secure CRT Functions in util.c and pyembed.c.
         defines.append(('_CRT_SECURE_NO_WARNINGS', 1))
-
+    platform = os.environ.get('PLATFORM')
     setup(name='jep',
           version=VERSION,
           description='Jep embeds CPython in Java',
@@ -107,10 +107,10 @@
                   name='jep',
                   sources=get_files('.c'),
                   define_macros=defines,
-                  libraries=get_java_libraries() + get_python_libs(),
-                  library_dirs=get_java_lib_folders(),
-                  extra_link_args=get_java_linker_args() + get_python_linker_args(),
-                  include_dirs=get_java_include() + ['src/main/c/Include', 'build/include',] + numpy_include,
+                  libraries=(['nativehelper'] if platform.startswith("android") else get_java_libraries()) + get_python_libs(),
+                  library_dirs=[] if platform.startswith("android") else get_java_lib_folders(),
+                  extra_link_args= ([] if platform.startswith("android") else get_java_linker_args()) + get_python_linker_args(),
+                  include_dirs= ([] if platform.startswith("android") else get_java_include()) + ['src/main/c/Include', 'build/include'] + numpy_include,
               )
           ],
 
@@ -141,4 +141,3 @@
           },
           zip_safe=False
     )
-
  1. When using android-ndk to install jep, you need to use python's crossenv to install it

This method needs to set a running target environment parameter: PLATFORM