Skip to content

[CI] macOS builds: "AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?" #384

Closed
@lum1n0us

Description

@lum1n0us

There is a common CI issue on macOS/x86-64 about pkgutil. ImpImporter triggered by 'rules_python"

ERROR: An error occurred during the fetch of repository 'fuzzing_py_deps':
   Traceback (most recent call last):
	File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12475e[29](https://github.com/proxy-wasm/proxy-wasm-cpp-host/actions/runs/8042165716/job/21962477785#step:9:30)2acf07553d/external/rules_python/python/pip_install/pip_repository.bzl", line 171, column 13, in _pip_repository_impl
		fail("rules_python failed: %s (%s)" % (result.stdout, result.stderr))
Error in fail: rules_python failed:  (Traceback (most recent call last):
  File "<frozen runpy>", line 189, in _run_module_as_main
  File "<frozen runpy>", line 148, in _get_module_details
  File "<frozen runpy>", line 112, in _get_module_details
  File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12[47](https://github.com/proxy-wasm/proxy-wasm-cpp-host/actions/runs/8042165716/job/21962477785#step:9:48)5e292acf07553d/external/rules_python/python/pip_install/extract_wheels/__init__.py", line 15, in <module>
    from python.pip_install.extract_wheels.lib import arguments, bazel, requirements
  File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12475e292acf07553d/external/rules_python/python/pip_install/extract_wheels/lib/bazel.py", line 9, in <module>
    from python.pip_install.extract_wheels.lib import namespace_pkgs, purelib, wheel
  File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12475e292acf07553d/external/rules_python/python/pip_install/extract_wheels/lib/purelib.py", line 6, in <module>
    from python.pip_install.extract_wheels.lib import wheel
  File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12475e292acf07553d/external/rules_python/python/pip_install/extract_wheels/lib/wheel.py", line 9, in <module>
    import pkg_resources
  File "/private/var/tmp/_bazel_runner/f7b5b126cb65bf12475e292acf07553d/external/pypi__setuptools/pkg_resources/__init__.py", line 2158, in <module>
    register_finder(pkgutil.ImpImporter, find_on_path)
                    ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?

It turns out that pkgutil.ImpImporter, as a long-deprecated class, has been removed from python 3.12. A proper way of fixing is upgrade rules_python.

But if using the latest rules_python 0.31, another error will be meet.

ERROR: /root/.cache/bazel/_bazel_root/adb5dd13720c6f98da219c2f1ac0ff1a/external/rules_python/python/private/common/py_executable.bzl:840:12: name 'RunEnvironmentInfo' is not defined

It is because RunEnvironmentInfo is not exposed in Bazel < 5.3. Currently, proxy-wasm-cpp-host is using Build label: 5.2.0.

So I am kind of stuck here, shall I ?

  • try with another version of rules_python
  • just upgrade bazel environment
  • something else

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions