Skip to content

Commit

Permalink
AVRO-3977: Use shutil.which instead of distutils
Browse files Browse the repository at this point in the history
Distutils is no longer shipped with Python as of 3.12
  • Loading branch information
kojiromike committed Apr 18, 2024
1 parent 8c0c2ff commit 6429a1d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lang/py/avro/test/test_tether_word_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
# limitations under the License.

import collections
import distutils.spawn
import os
import platform
import shutil
Expand Down Expand Up @@ -80,13 +79,13 @@ def _has_java(): # pragma: no coverage
telling you how to install java. This code does additional work around that
to be completely automatic.
"""
if platform.system() == "Darwin":
try:
output = subprocess.check_output("/usr/libexec/java_home", stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
output = e.output
return b"No Java runtime present" not in output
return bool(distutils.spawn.find_executable("java"))
if platform.system() != "Darwin":
return bool(shutil.which("java"))
try:
output = subprocess.check_output("/usr/libexec/java_home", stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
output = e.output
return b"No Java runtime present" not in output


@unittest.skipUnless(_has_java(), "No Java runtime present")
Expand Down

0 comments on commit 6429a1d

Please sign in to comment.