Repository: tensorflow
Issue: Build Error when installing dm-tree on Docker
Labels: stat:awaiting tensorflower,type:build/install,TF 2.15

### Issue type

Build/Install

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

binary

### TensorFlow version

2.15.0

### Custom code

No

### OS platform and distribution

Windows 11 Pro (Host), Docker container based on ubuntu:16.04

### Mobile device

_No response_

### Python version

3.11.6

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

**Steps to reproduce the error:**

1. Forked the TensorFlow master branch from the [TensorFlow GitHub repository](https://github.com/tensorflow/tensorflow).
2. Created a new branch within a GitHub workspace for making changes and running tests.
3. Attempted to run the TensorFlow Continuous Integration (CI) tests locally on a Windows machine using Docker, from the `/workspaces/tensorflow/` directory.
4. Executed the command `./tensorflow/tools/ci_build/ci_build.sh CPU ./tensorflow/tools/ci_build/ci_sanity.sh` to start the sanity check process.
5. Modified `Dockerfile.cpu` to ensure all script files use LF line endings and to set up the environment correctly.
6. Encountered errors when reaching the `RUN pip install packages` step within the `install_pip_packages.sh` script, specifically on the line `pip3 install dm-tree`.
7. Resolved several issues within `install_pip_packages.sh`, but hit a snag on installing `dm-tree`

### Standalone code to reproduce the issue

```shell
Updated `install_pip_packages.sh` as follows:

#!/usr/bin/env bash
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================

set -e

# Get the latest version of pip so it recognize manylinux2010
#wget https://bootstrap.pypa.io/get-pip.py
wget https://bootstrap.pypa.io/pip/3.5/get-pip.py
python3 get-pip.py
#python3.6 get-pip.py
rm -f get-pip.py

# Install pip packages from whl files to avoid the time-consuming process of
# building from source.

# Pin wheel==0.31.1 to work around issue
# https://github.com/pypa/auditwheel/issues/102
pip3 install wheel==0.31.1

# Install last working version of setuptools. This must happen before we install
# absl-py, which uses install_requires notation introduced in setuptools 20.5.
pip3 install --upgrade setuptools==39.1.0

pip3 install virtualenv

# Install six and future.
pip3 install --upgrade six==1.12.0
pip3 install "future>=0.17.1"

# Install absl-py.
pip3 install --upgrade absl-py

# Install werkzeug.
pip3 install --upgrade werkzeug==0.11.10

# Install bleach. html5lib will be picked up as a dependency.
pip3 install --upgrade bleach==2.0.0

# Install markdown.
pip3 install --upgrade markdown==2.6.8

# Install protobuf.
pip3 install --upgrade protobuf==3.16.0

# Remove obsolete version of six, which can sometimes confuse virtualenv.
rm -rf /usr/lib/python3/dist-packages/six*

# numpy needs to be installed from source to fix segfaults. See:
# https://github.com/tensorflow/tensorflow/issues/6968
# This workaround isn't needed for Ubuntu 16.04 or later.
if $(cat /etc/*-release | grep -q 14.04); then
  pip3 install --upgrade numpy==1.14.5
else
  pip3 install --upgrade numpy
fi

pip3 install scipy==1.4.1

pip3 install scikit-learn==0.18.1

# pandas required by `inflow`
pip3 install pandas==0.19.2

# Benchmark tests require the following:
pip3 install psutil
pip3 install py-cpuinfo

# pylint tests require the following version. pylint==1.6.4 hangs erratically,
# thus using the updated version of 2.5.3 only for python3 as python2 is EOL
# and this version is not available.
pip3 install pylint

# pycodestyle tests require the following:
pip3 install pycodestyle

pip3 install portpicker

# TensorFlow Serving integration tests require the following:
pip3 install grpcio

# Eager-to-graph execution needs astor, gast and termcolor:
pip3 install --upgrade astor
pip3 install --upgrade gast
pip3 install --upgrade termcolor

# Keras
pip3 install keras-nightly --no-deps
pip3 install --upgrade h5py

# Tensorboard
pip3 install tb-nightly --no-deps

# Argparse
pip3 install --upgrade argparse

# tree
pip3 install dm-tree

# tf.distribute multi worker tests require the following:
# Those tests are Python3 only.
pip3 install --upgrade dill
pip3 install --upgrade tblib
```


### Relevant log output

```shell
Collecting dm-tree
Downloading dm-tree-0.1.8.tar.gz (35 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lckm23fj/dm-tree_90fde797f8754ad2a98f0dc019c4e599/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lckm23fj/dm-tree_90fde797f8754ad2a98f0dc019c4e599/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-6h1yywpk
cwd: /tmp/pip-install-lckm23fj/dm-tree_90fde797f8754ad2a98f0dc019c4e599/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lckm23fj/dm-tree_90fde797f8754ad2a98f0dc019c4e599/setup.py", line 81
f'CMake must be installed to build the following extensions: {ext_names}'
^
SyntaxError: invalid syntax
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/f8/6d/f1997aac42e0f550c1e952a0b920eaa0bfc4d27d0421499881b934b969fc/dm-tree-0.1.8.tar.gz#sha256=0fcaabbb14e7980377439e7140bd05552739ca5e515ecb3119f234acee4b9430 (from https://pypi.org/simple/dm-tree/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Downloading dm-tree-0.1.7.tar.gz (35 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lckm23fj/dm-tree_8093f3e005e944759a173287c4759d86/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lckm23fj/dm-tree_8093f3e005e944759a173287c4759d86/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-uazji85z
cwd: /tmp/pip-install-lckm23fj/dm-tree_8093f3e005e944759a173287c4759d86/
Complete output (6 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lckm23fj/dm-tree_8093f3e005e944759a173287c4759d86/setup.py", line 81
f'CMake must be installed to build the following extensions: {ext_names}'
^
SyntaxError: invalid syntax
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/1c/ed/a9848a5d3dff0fc5c9c6f5120ae98c152ff47700a731958ff034a576ee27/dm-tree-0.1.7.tar.gz#sha256=30fec8aca5b92823c0e796a2f33b875b4dccd470b57e91e6c542405c5f77fd2a (from https://pypi.org/simple/dm-tree/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Downloading dm-tree-0.1.6.tar.gz (33 kB)
Requirement already satisfied: six>=1.12.0 in /usr/local/lib/python3.5/dist-packages (from dm-tree) (1.12.0)
Building wheels for collected packages: dm-tree
Building wheel for dm-tree (setup.py): started
Building wheel for dm-tree (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-4iudh8hy
cwd: /tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/
Complete output (32 lines):
/usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/tree
copying tree/tree_test.py -> build/lib.linux-x86_64-3.5/tree
copying tree/__init__.py -> build/lib.linux-x86_64-3.5/tree
copying tree/tree_benchmark.py -> build/lib.linux-x86_64-3.5/tree
running build_ext
bazel build //tree:_tree --symlink_prefix=build/temp.linux-x86_64-3.5/bazel- --compilation_mode=opt
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Loading:
Loading:
Loading:
Loading: 0 packages loaded
Loading: 0 packages loaded
currently loading: tree
Loading: 0 packages loaded
currently loading: tree
Analyzing: target //tree:_tree (1 packages loaded, 0 targets configured)
ERROR: /root/.cache/bazel/_bazel_root/3f0a395690e111f9618f699b5feff3a0/external/bazel_tools/platforms/BUILD:89:6: in alias rule @bazel_tools//platforms:windows: Constraints from @bazel_tools//platforms have been removed. Please use constraints from @platforms repository embedded in Bazel, or preferably declare dependency on https://github.com/bazelbuild/platforms. See https://github.com/bazelbuild/bazel/issues/8622 for details.
ERROR: /root/.cache/bazel/_bazel_root/3f0a395690e111f9618f699b5feff3a0/external/bazel_tools/platforms/BUILD:89:6: Analysis of target '@bazel_tools//platforms:windows' failed
ERROR: /tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/tree/BUILD:27:18: errors encountered resolving select() keys for //tree:_tree
ERROR: Analysis of target '//tree:_tree' failed; build aborted:
INFO: Elapsed time: 14.615s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (6 packages loaded, 7 targets configured)
error: command 'bazel' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for dm-tree
Running setup.py clean for dm-tree
Failed to build dm-tree
Installing collected packages: dm-tree
Running setup.py install for dm-tree: started
Running setup.py install for dm-tree: finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-09ok4qc1/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.5/dm-tree
cwd: /tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/
Complete output (25 lines):
/usr/lib/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.5
creating build/lib.linux-x86_64-3.5/tree
copying tree/tree_test.py -> build/lib.linux-x86_64-3.5/tree
copying tree/__init__.py -> build/lib.linux-x86_64-3.5/tree
copying tree/tree_benchmark.py -> build/lib.linux-x86_64-3.5/tree
running build_ext
bazel build //tree:_tree --symlink_prefix=build/temp.linux-x86_64-3.5/bazel- --compilation_mode=opt
Loading:
Loading:
Loading: 0 packages loaded
Analyzing: target //tree:_tree (0 packages loaded, 0 targets configured)
ERROR: /root/.cache/bazel/_bazel_root/3f0a395690e111f9618f699b5feff3a0/external/bazel_tools/platforms/BUILD:89:6: in alias rule @bazel_tools//platforms:windows: Constraints from @bazel_tools//platforms have been removed. Please use constraints from @platforms repository embedded in Bazel, or preferably declare dependency on https://github.com/bazelbuild/platforms. See https://github.com/bazelbuild/bazel/issues/8622 for details.
ERROR: /root/.cache/bazel/_bazel_root/3f0a395690e111f9618f699b5feff3a0/external/bazel_tools/platforms/BUILD:89:6: Analysis of target '@bazel_tools//platforms:windows' failed
ERROR: /tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/tree/BUILD:27:18: errors encountered resolving select() keys for //tree:_tree
ERROR: Analysis of target '//tree:_tree' failed; build aborted:
INFO: Elapsed time: 0.662s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
error: command 'bazel' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lckm23fj/dm-tree_70352c37b8984f0f92e3dca56fbee6a5/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-09ok4qc1/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.5/dm-tree Check the logs for full command output
```