diff --git a/sdks/python/apache_beam/runners/portability/stager.py b/sdks/python/apache_beam/runners/portability/stager.py index 4afe5eaaa370..7f889eac8d9a 100644 --- a/sdks/python/apache_beam/runners/portability/stager.py +++ b/sdks/python/apache_beam/runners/portability/stager.py @@ -49,9 +49,9 @@ import glob import hashlib -import importlib.util import logging import os +import pkgutil import shutil import sys import tempfile @@ -774,7 +774,7 @@ def _build_setup_package(setup_file, # type: str if build_setup_args is None: # if build is installed in the user env, use it to # build the sdist else fallback to legacy setup.py sdist call. - if importlib.util.find_spec('build'): + if pkgutil.find_loader('build') is not None: build_setup_args = [ Stager._get_python_executable(), '-m',