kou commented on code in PR #39502:
URL: https://github.com/apache/arrow/pull/39502#discussion_r1444590028
##########
dev/archery/archery/integration/tester_java.py:
##########
@@ -95,14 +95,18 @@ def setup_jpype():
class _CDataBase:
def __init__(self, debug, args):
- import jpype
self.debug = debug
self.args = args
self.ffi = cdata.ffi()
- setup_jpype()
- # JPype pointers to java.io, org.apache.arrow...
- self.java_io = jpype.JPackage("java").io
- self.java_arrow = jpype.JPackage("org").apache.arrow
+ try:
+ import jpype
+ except ImportError:
+ log("jpype is not installed. Skipping setup.")
Review Comment:
How about skipping all Java tests something like the following? (I haven't
run the snippet. Sorry.)
```diff
diff --git a/dev/archery/archery/integration/runner.py
b/dev/archery/archery/integration/runner.py
index 7fadb7e47..c84c01168 100644
--- a/dev/archery/archery/integration/runner.py
+++ b/dev/archery/archery/integration/runner.py
@@ -552,7 +552,11 @@ def run_all_tests(with_cpp=True, with_java=True,
with_js=True,
testers.append(CppTester(**kwargs))
if with_java:
- testers.append(JavaTester(**kwargs))
+ available, reason = JavaTester.check_availability():
+ if available:
+ testers.append(JavaTester(**kwargs))
+ else:
+ log(f"WARNING: Java tester isn't available: {reason}")
if with_js:
testers.append(JSTester(**kwargs))
diff --git a/dev/archery/archery/integration/tester_java.py
b/dev/archery/archery/integration/tester_java.py
index 6cd1afa64..00abf3e22 100644
--- a/dev/archery/archery/integration/tester_java.py
+++ b/dev/archery/archery/integration/tester_java.py
@@ -235,6 +235,14 @@ class JavaTester(Tester):
name = 'Java'
+ @staticmethod
+ def check_availability():
+ try:
+ import jpype
+ return True
+ except ImportError as error:
+ return False, f"jpype isn't available: {error}"
+
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Detect whether we're on Java 8 or Java 9+
```
##########
dev/archery/archery/integration/tester_java.py:
##########
@@ -95,14 +95,18 @@ def setup_jpype():
class _CDataBase:
def __init__(self, debug, args):
- import jpype
self.debug = debug
self.args = args
self.ffi = cdata.ffi()
- setup_jpype()
- # JPype pointers to java.io, org.apache.arrow...
- self.java_io = jpype.JPackage("java").io
- self.java_arrow = jpype.JPackage("org").apache.arrow
+ try:
+ import jpype
+ except ImportError:
+ log("jpype is not installed. Skipping setup.")
+ else:
+ setup_jpype()
+ # JPype pointers to java.io, org.apache.arrow...
+ self.java_io = jpype.JPackage("java").io
+ self.java_arrow = jpype.JPackage("org").apache.arrow
self.java_allocator = self._make_java_allocator()
Review Comment:
```suggestion
self.java_allocator = self._make_java_allocator()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]