Author: Alastair McKinstry <mckinstry@debian.org>
Description: Add libjvm.so to path
Last-Updated: 2016-09-06
Forwarded: not-needed

Index: jpy-0.8/jpyutil.py
===================================================================
--- jpy-0.8.orig/jpyutil.py
+++ jpy-0.8/jpyutil.py
@@ -30,7 +30,6 @@ import ctypes
 import ctypes.util
 import logging
 
-
 # Uncomment for debugging
 # logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
 
@@ -154,9 +153,21 @@ def find_jvm_dll_file(java_home_dir=None
 
     return jvm_dll_path
 
+def get_arch():
+    """ Get arch name on Debian """
+    from subprocess import check_output
+    # arch = 'amd64' if PYTHON_64BIT else 'i386'
+    arch = check_output(['dpkg-architecture','-q', 'DEB_BUILD_ARCH_CPU']).strip()
+    if type(arch) != str:  # python3
+        arch = arch.decode('utf-8')
+    other_names = { 'ppc64el': 'ppc64le', 'arm64' : 'aarch64',
+                    'powerpc' : 'ppc', 'sparc64' : 'sparcv9' }
+    if arch in other_names:
+        arch = other_names[arch]
+    return arch
 
 def _get_jvm_lib_dirs(java_home_dir):
-    arch = 'amd64' if PYTHON_64BIT else 'i386'
+    arch  = get_arch()
     return (os.path.join(java_home_dir, 'bin'),
             os.path.join(java_home_dir, 'bin', 'server'),
             os.path.join(java_home_dir, 'bin', 'client'),
@@ -193,6 +204,9 @@ def _find_jvm_dll_file(java_home_dir):
         search_dirs += _get_jvm_lib_dirs(jre_home_dir)
     search_dirs += _get_jvm_lib_dirs(java_home_dir)
 
+    arch = get_arch()
+    search_dirs += "/usr/lib/jvm/default-java/jre/lib/%s/server" % arch
+
     search_dirs = _add_paths_if_exists([], *search_dirs)
 
     if platform.system() == 'Windows':
