Fix Linux book render Python path

This commit is contained in:
Vijay Janapa Reddi
2026-06-03 02:55:20 -04:00
parent 3c0a4ec9c6
commit 2c2d4f4e78
6 changed files with 11 additions and 14 deletions
+6 -9
View File
@@ -440,14 +440,11 @@ jobs:
- name: 🧪 Preflight toolchain (Linux)
if: matrix.platform == 'linux' && matrix.enabled
working-directory: ${{ vars.BOOK_QUARTO }}
env:
# Layout: <repo>/mlsysim/ is the project dir; <repo>/mlsysim/mlsysim/
# is the actual Python package. Put the project dir on PYTHONPATH so
# submodule imports like `mlsysim.core` resolve without an editable
# install. Parallels the fix in book/tests/test_units.py.
PYTHONPATH: ${{ github.workspace }}/mlsysim:${{ github.workspace }}
run: |
set -eu
# In GitHub's Linux container jobs, $GITHUB_WORKSPACE is the in-container
# checkout path. The github.workspace expression is the host path.
export PYTHONPATH="$GITHUB_WORKSPACE/mlsysim:$GITHUB_WORKSPACE${PYTHONPATH:+:$PYTHONPATH}"
echo "🧪 Running Linux toolchain preflight checks..."
run_check() {
CHECK_NAME="$1"
@@ -468,6 +465,7 @@ jobs:
run_check "python3 on PATH" "command -v python3 >/dev/null"
run_check "python3 version" "python3 --version"
run_check "mlsysim import" "python3 -c \"import mlsysim,sys; print('mlsysim:', mlsysim.__file__); print('python:', sys.executable)\""
run_check "book tools import" "python3 -c \"from book.tools.figures import style; print('book.tools.figures:', style.__file__)\""
run_check "mlsysim.core import" "python3 -c \"import mlsysim.core; print('mlsysim.core:', mlsysim.core.__file__)\""
run_check "Rscript on PATH" "command -v Rscript >/dev/null"
run_check "Rscript version" "Rscript --version | sed -n '1p'"
@@ -594,11 +592,10 @@ jobs:
if: matrix.platform == 'linux' && matrix.enabled
working-directory: ${{ vars.BOOK_QUARTO }}
env:
# See preflight comment: <repo>/mlsysim/ must be on PYTHONPATH so
# Quarto's embedded Python can resolve `mlsysim.core` during render.
PYTHONPATH: ${{ github.workspace }}/mlsysim:${{ github.workspace }}
CHROMIUM_FLAGS: "--no-sandbox"
run: |
# Keep the in-container checkout first on PYTHONPATH for render-time imports.
export PYTHONPATH="$GITHUB_WORKSPACE/mlsysim:$GITHUB_WORKSPACE${PYTHONPATH:+:$PYTHONPATH}"
# Ensure Quarto can find Chromium (installed by Dockerfile but .bashrc not sourced in CI)
if [ -f "$HOME/.local/share/quarto/chromium/chrome" ]; then
export QUARTO_CHROMIUM="$HOME/.local/share/quarto/chromium/chrome"
@@ -117,7 +117,7 @@ bibliography:
execute:
env:
PYTHONPATH: "../..:../../mlsysim"
PYTHONPATH: "../..:../../mlsysim:../../../../..:../../../../../mlsysim"
MPLBACKEND: "Agg"
metadata-files:
+1 -1
View File
@@ -138,7 +138,7 @@ metadata-files:
execute:
env:
PYTHONPATH: "../..:../../mlsysim"
PYTHONPATH: "../..:../../mlsysim:../../../../..:../../../../../mlsysim"
MPLBACKEND: "Agg"
editor:
@@ -119,7 +119,7 @@ bibliography:
execute:
env:
PYTHONPATH: "../..:../../mlsysim"
PYTHONPATH: "../..:../../mlsysim:../../../../..:../../../../../mlsysim"
MPLBACKEND: "Agg"
metadata-files:
+1 -1
View File
@@ -141,7 +141,7 @@ metadata-files:
execute:
env:
PYTHONPATH: "../..:../../mlsysim"
PYTHONPATH: "../..:../../mlsysim:../../../../..:../../../../../mlsysim"
MPLBACKEND: "Agg"
editor:
@@ -1,6 +1,6 @@
execute:
env:
PYTHONPATH: "../..:../../mlsysim"
PYTHONPATH: "../..:../../mlsysim:../../../../..:../../../../../mlsysim"
MPLBACKEND: "Agg"
editor: