GoogleCloudPlatform / GoogleCloudPlatform/cloud-builders

[BUG] Bazel image missing `python3-distutils`

Open
#900 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
1.5k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

Seems `python3-distutils` is missing from ubuntue even if python3 is installed.

`dnsutils` is called by bazel while acquiring pip modules specified in the bazel `WORKSPACE`

## Affected builder image

`gcr.io/cloud-builders/bazel`

## Expected Behavior

build python3 application using cloud-builders bazel image

## Actual Behavior

fails with full trace below

## Steps to Reproduce the Problem

using `Dockerfile` from cloud-builders [here](https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/bazel)

```
docker run -ti gcr.io/gcp-runtimes/ubuntu_20_0_4 /bin/bash
```

then run:

```bash
apt-get update && \
apt-get -y install \
python \
python3 \
python-pkg-resources \
python3-pkg-resources \
software-properties-common \
unzip

# with python2
root@96b4d92026d6:/# python
Python 2.7.18 (default, Jul 1 2022, 12:27:04)
[GCC 9.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.cmd import Command as DistutilsCommand
>>>

# with python3
root@96b4d92026d6:/# python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.cmd import Command as DistutilsCommand
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'distutils.cmd'

# install
apt-get install python3-distutils

root@96b4d92026d6:/# python3
Python 3.8.10 (default, Mar 13 2023, 10:26:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from distutils.cmd import Command as DistutilsCommand
>>>
```

## Additional Info

full trace while using image

```
Step #0 - "build": ERROR: /workspace/WORKSPACE:24:13: fetching whl_library rule //external:my_deps_flask: Traceback (most recent call last):
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/rules_python/python/pip_install/pip_repository.bzl", line 688, column 13, in _whl_library_impl
Step #0 - "build": fail("whl_library %s failed: %s (%s)" % (rctx.attr.name, result.stdout, result.stderr))
Step #0 - "build": Error in fail: whl_library my_deps_flask failed: (Traceback (most recent call last):
Step #0 - "build": File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
Step #0 - "build": return _run_code(code, main_globals, None,
Step #0 - "build": File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
Step #0 - "build": exec(code, run_globals)
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/__main__.py", line 29, in
Step #0 - "build": from pip._internal.cli.main import main as _main
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/cli/main.py", line 9, in
Step #0 - "build": from pip._internal.cli.autocompletion import autocomplete
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/cli/autocompletion.py", line 10, in
Step #0 - "build": from pip._internal.cli.main_parser import create_main_parser
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/cli/main_parser.py", line 9, in
Step #0 - "build": from pip._internal.build_env import get_runnable_pip
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/build_env.py", line 20, in
Step #0 - "build": from pip._internal.cli.spinners import open_spinner
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/cli/spinners.py", line 9, in
Step #0 - "build": from pip._internal.utils.logging import get_indentation
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/utils/logging.py", line 29, in
Step #0 - "build": from pip._internal.utils.misc import ensure_dir
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/utils/misc.py", line 42, in
Step #0 - "build": from pip._internal.locations import get_major_minor_version
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/locations/__init__.py", line 67, in
Step #0 - "build": from . import _distutils
Step #0 - "build": File "/builder/home/.cache/bazel/_bazel_root/eab0d61a99b6696edb3d2aff87b585e8/external/pypi__pip/pip/_internal/locations/_distutils.py", line 20, in
Step #0 - "build": from distutils.cmd import Command as DistutilsCommand
Step #0 - "build": ModuleNotFoundError: No module named 'distutils.cmd'
Step #0 - "build": Traceback (most recent call last):
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.