From 7d5a8fa6a434c070e21565d53a991610c204d6c1 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 27 Jul 2019 18:30:25 -0400 Subject: [PATCH] Adjust java detection so it's more likely to work on jdks that write -version to stderr. --- Makefile | 2 +- setup.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 97c6bae..0c08262 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ PYTHON=python NOSETESTS=nosetests endif -JAVA_TARGET ?= $(shell javac -version | $(PYTHON) -c "import re; print('1.6' if int(re.findall(r'\d+', input())[0]) < 12 else '1.7')" ) +JAVA_TARGET ?= $(shell $(PYTHON) -c "import re; print('1.6' if int(re.findall(r'\d+', '$(shell javac -version 2>&1)')[0]) < 12 else '1.7')" ) JAVAC_OPTS=-target $(JAVA_TARGET) -source $(JAVA_TARGET) JAVAC=javac $(JAVAC_OPTS) diff --git a/setup.py b/setup.py index b431200..c8ec5fc 100644 --- a/setup.py +++ b/setup.py @@ -95,7 +95,8 @@ def compile_native_invocation_handler(*possible_homes): source_level = '1.6' # We have to check what version of javac this is, because -target 1.6 is # no longer supported on JDKs >= 12. - javac_version = subprocess.check_output([javac, '-version']) + javac_version = subprocess.check_output([javac, '-version'], + stderr=subprocess.STDOUT) for m in re.finditer(r'\d+', javac_version.decode('ascii')): if int(m.group(0)) >= 12: source_level = '1.7'