mirror of https://github.com/kivy/pyjnius.git
Use Python standard library which instead of OS which
This commit is contained in:
parent
1692c95099
commit
13e741dc8b
27
jnius/env.py
27
jnius/env.py
|
@ -16,6 +16,11 @@ log = getLogger(__name__)
|
||||||
|
|
||||||
PY2 = sys.version_info.major < 3
|
PY2 = sys.version_info.major < 3
|
||||||
|
|
||||||
|
if PY2:
|
||||||
|
from distutils.spawn import find_executable as which
|
||||||
|
else:
|
||||||
|
from shutil import which
|
||||||
|
|
||||||
machine = machine() # not expected to change at runtime
|
machine = machine() # not expected to change at runtime
|
||||||
|
|
||||||
# This dictionary converts values from platform.machine()
|
# This dictionary converts values from platform.machine()
|
||||||
|
@ -102,11 +107,12 @@ def get_jre_home(platform):
|
||||||
jre_home = join(JAVA_HOME, 'jre')
|
jre_home = join(JAVA_HOME, 'jre')
|
||||||
|
|
||||||
if platform != 'win32' and not jre_home:
|
if platform != 'win32' and not jre_home:
|
||||||
jre_home = realpath(
|
try:
|
||||||
check_output(
|
jre_home = realpath(
|
||||||
split('which java')
|
which('java')
|
||||||
).decode('utf-8').strip()
|
).replace('bin/java', '')
|
||||||
).replace('bin/java', '')
|
except TypeError:
|
||||||
|
raise Exception('Unable to find java')
|
||||||
|
|
||||||
if platform == 'win32':
|
if platform == 'win32':
|
||||||
if isinstance(jre_home, bytes):
|
if isinstance(jre_home, bytes):
|
||||||
|
@ -132,11 +138,12 @@ def get_jdk_home(platform):
|
||||||
jdk_home = TMP_JDK_HOME
|
jdk_home = TMP_JDK_HOME
|
||||||
|
|
||||||
else:
|
else:
|
||||||
jdk_home = realpath(
|
try:
|
||||||
check_output(
|
jdk_home = realpath(
|
||||||
['which', 'javac']
|
which('javac')
|
||||||
).decode('utf-8').strip()
|
).replace('bin/javac', '')
|
||||||
).replace('bin/javac', '')
|
except TypeError:
|
||||||
|
raise Exception('Unable to find javac')
|
||||||
|
|
||||||
if not jdk_home or not exists(jdk_home):
|
if not jdk_home or not exists(jdk_home):
|
||||||
raise Exception('Unable to determine JDK_HOME')
|
raise Exception('Unable to determine JDK_HOME')
|
||||||
|
|
Loading…
Reference in New Issue