Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get JDK/JRE path pythonically #399

Merged
merged 6 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: generic

os:
- osx
- linux
- osx

env:
- PYTHON_VERSION="2.7" JAVA_VERSION="8"
Expand Down
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
import subprocess32 as subprocess
except ImportError:
import subprocess
import os
from os import environ
from os.path import dirname, join, exists
from os.path import dirname, join, exists, realpath
import sys
from platform import machine
from setup_sdist import SETUP_KWARGS
Expand Down Expand Up @@ -165,12 +166,11 @@ def compile_native_invocation_handler(*possible_homes):
JDK_HOME = TMP_JDK_HOME

else:
JDK_HOME = subprocess.Popen(
'readlink -f `which javac` | sed "s:bin/javac::"',
shell=True, stdout=subprocess.PIPE).communicate()[0].strip()

if JDK_HOME is not None and not PY2:
JDK_HOME = JDK_HOME.decode('utf-8')
JDK_HOME = realpath(
subprocess.check_output(
['which', 'javac']
).decode('utf-8').strip()
).replace('bin/javac', '')

if not JDK_HOME or not exists(JDK_HOME):
raise Exception('Unable to determine JDK_HOME')
Expand All @@ -180,9 +180,11 @@ def compile_native_invocation_handler(*possible_homes):
JRE_HOME = join(JDK_HOME, 'jre')

if PLATFORM != 'win32' and not JRE_HOME:
JRE_HOME = subprocess.Popen(
'readlink -f `which java` | sed "s:bin/java::"',
shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
JRE_HOME = realpath(
subprocess.check_output(
['which', 'java']
).decode('utf-8').strip()
).replace('bin/java', '')

# This dictionary converts values from platform.machine()
# to a "cpu" string. It is needed to set the correct lib path,
Expand Down