@@ -86,17 +86,62 @@ jobs:
8686 # Bazel's system_python repository resolves headers relative to the
8787 # interpreter installed by actions/setup-python. The self-hosted
8888 # ml-build container does not provide Python.h under that prefix, so
89- # point the managed interpreter include dir at the system headers.
89+ # copy the system headers into the managed interpreter include dir.
90+ # A real directory copy is more robust here than a symlink because
91+ # Bazel's repository setup may materialize or traverse this path in
92+ # ways that do not preserve symlink behavior.
9093 sudo mkdir -p "${pythonLocation}/include"
91- if [ ! -f "${pythonLocation}/include/${py_abi}/Python.h" ]; then
92- sudo rm -rf "${pythonLocation}/include/${py_abi}"
93- sudo ln -s "/usr/include/${py_abi}" "${pythonLocation}/include/${py_abi}"
94- fi
94+ sudo rm -rf "${pythonLocation}/include/${py_abi}"
95+ sudo mkdir -p "${pythonLocation}/include/${py_abi}"
96+ sudo cp -a "/usr/include/${py_abi}/." "${pythonLocation}/include/${py_abi}/"
9597 test -f "${pythonLocation}/include/${py_abi}/Python.h"
98+ - name : ' Debug Python toolchain'
99+ run : |
100+ py_abi="python${{ matrix.python_version }}"
101+ echo "pythonLocation=${pythonLocation}"
102+ echo "PATH=${PATH}"
103+ which python
104+ python --version
105+ command -v python3.10-config || true
106+ python3.10-config --includes || true
107+ python - <<'PY'
108+ import os
109+ import pathlib
110+ import sys
111+ import sysconfig
112+
113+ print("sys.executable =", sys.executable)
114+ for key in ("include", "platinclude", "stdlib", "platstdlib", "scripts", "data"):
115+ print(f"{key} =", sysconfig.get_path(key))
116+ for key in ("INCLUDEPY", "CONFINCLUDEPY", "LIBDIR", "LDLIBRARY", "MULTIARCH"):
117+ print(f"{key} =", sysconfig.get_config_var(key))
118+ include_dir = pathlib.Path(sysconfig.get_path("include"))
119+ print("include_dir exists =", include_dir.exists(), include_dir)
120+ print("Python.h exists =", (include_dir / "Python.h").exists())
121+ print("pythonLocation =", os.environ.get("pythonLocation"))
122+ PY
123+ ls -la "${pythonLocation}" || true
124+ ls -la "${pythonLocation}/include" || true
125+ ls -la "${pythonLocation}/include/${py_abi}" || true
96126 - name : ' Check Pip state'
97127 run : pip freeze --all
98128 - name : ' Bazel: fetch'
99129 run : bazel fetch //tensorboard/...
130+ - name : ' Debug Bazel system_python repo'
131+ run : |
132+ output_base="$(bazel info output_base)"
133+ echo "output_base=${output_base}"
134+ find "${output_base}/external/system_python" -maxdepth 3 \
135+ \( -name 'Python.h' -o -name 'BUILD.bazel' -o -name 'WORKSPACE' \) \
136+ -print | sort || true
137+ if [ -f "${output_base}/external/system_python/BUILD.bazel" ]; then
138+ sed -n '1,200p' "${output_base}/external/system_python/BUILD.bazel"
139+ fi
140+ if [ -d "${output_base}/external/system_python/python" ]; then
141+ ls -la "${output_base}/external/system_python/python"
142+ else
143+ echo "system_python/python directory not found"
144+ fi
100145 - name : ' Bazel: build'
101146 # Note we suppress a flood of warnings from the proto compiler.
102147 # Googlers see b/222706811 & b/182876485 discussion and preconditions
0 commit comments