Skip to content

Commit

Permalink
Move get_cpu guessing into _possible_lib_location (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
misl6 authored Jun 5, 2022
1 parent fe46b03 commit 57e3ea0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions jnius/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,9 @@ def get_jnius_lib_location(self):
)
return libjvm_override_path

cpu = get_cpu()
platform = self.platform
log.debug(
"looking for libjvm to initiate pyjnius, cpu is %s, platform is %s",
cpu, platform
)
lib_locations = self._possible_lib_locations(cpu)
log.debug("looking for libjvm to initiate pyjnius, platform is %s", platform)
lib_locations = self._possible_lib_locations()
for location in lib_locations:
full_lib_location = join(self.home, location)
if exists(full_lib_location):
Expand All @@ -193,7 +189,7 @@ def get_jnius_lib_location(self):
% [join(self.home, loc) for loc in lib_locations]
)

def _possible_lib_locations(self, cpu):
def _possible_lib_locations(self):
'''
Returns a list of relative possible locations for the Java library.
Used by the default implementation of get_jnius_lib_location()
Expand Down Expand Up @@ -223,11 +219,16 @@ def _get_platform_include_dir(self):
else:
return join(self.home, 'include', 'linux')

def _possible_lib_locations(self, cpu):
def _possible_lib_locations(self):
root = self.home
if root.endswith('jre'):
root = root[:-3]

cpu = get_cpu()
log.debug(
f"Platform {self.platform} may need cpu in path to find libjvm, which is: {cpu}"
)

return [
'lib/server/libjvm.so',
'jre/lib/{}/default/libjvm.so'.format(cpu),
Expand All @@ -239,7 +240,7 @@ class MacOsXJavaLocation(UnixJavaLocation):
def _get_platform_include_dir(self):
return join(self.home, 'include', 'darwin')

def _possible_lib_locations(self, cpu):
def _possible_lib_locations(self):
if '1.6' in self.home:
return ['../Libraries/libjvm.dylib'] # TODO what should this be resolved to?

Expand Down

0 comments on commit 57e3ea0

Please sign in to comment.