Skip to content

Official Codebase of 3DCodeVerse

Python

setup.sh: verify the interpreter we installed into, and require pip up front

gaoypeng7b97791e0f2f
diff --git a/harness/docs/INSTALL.md b/harness/docs/INSTALL.md
index b577cf8b..36ae5dbd 100644
--- a/harness/docs/INSTALL.md
+++ b/harness/docs/INSTALL.md
@@ -24,6 +24,8 @@ Once installed, read `docs/RUNBOOK.md` (how to run), `docs/ARCHITECTURE.md`
```bash
git clone <repo> 3dcodeverse && cd 3dcodeverse
+python3 -m venv .venv && source .venv/bin/activate # see §3 — a distro python3 is
+ # PEP 668 and pip will refuse it
bash harness/scripts/setup.sh # python + node deps + chrome + doctor
```
@@ -80,6 +82,7 @@ in `scripts/setup.sh` — the test will then tell you which shims to delete.
| what | required? | verified here | how it degrades without it |
|---|---|---|---|
| **Python 3.10+** | yes | 3.13.9 (`/home/yipeng/miniconda3/bin/python`) | nothing runs; `requires-python = ">=3.10"` (§2.1) |
+| **pip + venv** | yes | pip 25.3, `python -m venv` | `scripts/setup.sh` cannot install the package. A stock Debian/Ubuntu `/usr/bin/python3` ships **without** pip and is PEP 668 `EXTERNALLY-MANAGED`, so `pip install -e harness` refuses even once pip is present: `sudo apt install python3-venv python3-pip`, then use a virtualenv |
| **git** | yes | 2.53.0 | run workspaces are git repos (one commit per round); `Workspace.create()` and the flywheel trajectory/pair miners fail |
| **node ≥ 20.6** | yes, except for the `graphics` track | v24.14.0 (npm 11.9.0) | the `threejs` / `scene_threejs` languages disappear **and no object renders happen at all**: `spatial/render.py` renders *every* GLB (Blender-built and CadQuery-built included) with three.js in headless Chrome. Only `graphics` (moderngl) is node-free |
| **Blender 4.2+ / 5.x** | optional | 5.0.1 (`~/.local/bin/blender-5.0`) | `blender` and `urdf_blender` languages unavailable → the `static_object` default language and the whole `articulated_object` track cannot build (`BlenderNotFoundError`); scenes lose planner-chosen bpy GLB assets |
@@ -104,8 +107,11 @@ Layout: the harness is the `harness/` subdirectory (python dist `3dcodeverse`,
import package `codeverse`, CLIs `3dcodeverse` and `3dcv`). See the repo
`README.md` for the other top-level components.
-A virtualenv is recommended but not required — this box installs into a conda
-base env:
+Use a virtualenv (or a conda env — this box installs into a conda base env). It is
+only optional when your interpreter already owns its site-packages: a distro
+`/usr/bin/python3` is PEP 668 `EXTERNALLY-MANAGED` and pip will refuse to install into
+it. `scripts/setup.sh` checks for pip and for that marker up front and tells you which
+of the two you hit.
```bash
python -m venv .venv && source .venv/bin/activate # or: conda create -n cv3d python=3.13
diff --git a/harness/scripts/setup.sh b/harness/scripts/setup.sh
index 0d9a8a36..62b1282b 100755
--- a/harness/scripts/setup.sh
+++ b/harness/scripts/setup.sh
@@ -77,6 +77,34 @@ PY_VER="$("$PY" -c 'import sys; print("%d.%d.%d" % sys.version_info[:3])')"
|| die "python 3.$MIN_PY_MINOR+ required, found $PY_VER ($PY)"
info "python $PY_VER ($("$PY" -c 'import sys; print(sys.executable)'))"
+# pip is a prerequisite, not a given: Debian/Ubuntu ship /usr/bin/python3 without it and
+# mark it PEP 668 (EXTERNALLY-MANAGED), so the TL;DR install used to pass this whole block
+# and then abort on the bare line "/usr/bin/python3: No module named pip" with no guidance.
+if [ "$DO_PYTHON" -eq 1 ]; then
+ if ! "$PY" -m pip --version >/dev/null 2>&1; then
+ die "python has no pip: '$PY -m pip' is missing.
+ Create a virtualenv and re-run with it (recommended — docs/INSTALL.md §3):
+ $PY -m venv .venv && . .venv/bin/activate && bash $0
+ On Debian/Ubuntu the venv and pip modules are packaged separately:
+ sudo apt install python3-venv python3-pip"
+ fi
+ PIP_VER="$("$PY" -m pip --version | awk '{print $2}')"
+ # PEP 668: pip refuses to install into an externally-managed interpreter, so say so
+ # here rather than letting `pip install -e` fail three steps later.
+ if "$PY" - <<'PEP668'
+import os, sys, sysconfig
+managed = os.path.exists(os.path.join(sysconfig.get_path("stdlib"), "EXTERNALLY-MANAGED"))
+sys.exit(0 if managed and sys.prefix == sys.base_prefix else 1)
+PEP668
+ then
+ die "python is PEP 668 externally-managed and this is not a virtualenv: $PY
+ pip will refuse to install here. Create one and re-run with it:
+ $PY -m venv .venv && . .venv/bin/activate && bash $0
+ (docs/INSTALL.md §3)"
+ fi
+ info "pip $PIP_VER"
+fi
+
command -v git >/dev/null 2>&1 || die "git not found (every round is a git commit in the run workspace)"
info "git $(git --version | awk '{print $3}')"
@@ -141,11 +169,18 @@ fi
# ----------------------------------------------------------------------- doctor
if [ "$DO_DOCTOR" -eq 1 ]; then
step "3dcodeverse doctor"
- if command -v 3dcodeverse >/dev/null 2>&1; then
+ # Verify what we just INSTALLED, not whatever happens to be first on PATH. With
+ # --python (the documented way to install into a non-activated interpreter) the venv's
+ # own entry point is not on PATH, so the old `command -v 3dcodeverse` branch ran a
+ # pre-existing install and printed an all-green table for an environment this script
+ # never touched — the closing doctor is the installer's only verification.
+ if "$PY" -c 'import codeverse' >/dev/null 2>&1; then
+ "$PY" -m codeverse.cli.main doctor ${DOCTOR_ARGS[@]+"${DOCTOR_ARGS[@]}"} || true
+ elif command -v 3dcodeverse >/dev/null 2>&1; then
+ info "codeverse not importable by $PY — falling back to the 3dcodeverse on PATH"
3dcodeverse doctor ${DOCTOR_ARGS[@]+"${DOCTOR_ARGS[@]}"} || true
else
- info "3dcodeverse not on PATH — falling back to python -m codeverse.cli.main"
- "$PY" -m codeverse.cli.main doctor ${DOCTOR_ARGS[@]+"${DOCTOR_ARGS[@]}"} || true
+ info "codeverse not importable by $PY and 3dcodeverse not on PATH — skipping doctor"
fi
fi
diff --git a/harness/tests/install/test_docs.py b/harness/tests/install/test_docs.py
index 1a1259cb..4b9cb001 100644
--- a/harness/tests/install/test_docs.py
+++ b/harness/tests/install/test_docs.py
@@ -283,3 +283,59 @@ def test_architecture_package_map_covers_every_module():
)
assert not missing, (
"modules missing from the docs/ARCHITECTURE.md package map:\n " + "\n ".join(missing))
+
+
+def test_setup_verifies_the_interpreter_it_installed_into(tmp_path) -> None:
+ """PORT-6: the closing doctor is the installer's only verification, and it used to
+ run `command -v 3dcodeverse` first. With `--python` — the documented flag for
+ installing into a NON-activated interpreter — that venv's entry point is not on PATH,
+ so setup.sh ran a pre-existing install (here /home/.../miniconda3/bin/3dcodeverse,
+ python 3.13) and printed an all-green table for an environment it never touched.
+ An installer must verify what it installed."""
+ import sys
+
+ fake = tmp_path / "bin"
+ fake.mkdir()
+ impostor = fake / "3dcodeverse"
+ impostor.write_text("#!/bin/sh\necho WRONG_INSTALL_ON_PATH\n")
+ impostor.chmod(0o755)
+
+ env = dict(os.environ, PATH=f"{fake}{os.pathsep}{os.environ['PATH']}")
+ proc = subprocess.run(
+ ["bash", str(SETUP), "--python", sys.executable, "--no-node", "--no-chrome", "--no-gpu", "--no-python"],
+ capture_output=True, text=True, timeout=300, env=env)
+ assert "WRONG_INSTALL_ON_PATH" not in proc.stdout + proc.stderr, (
+ "setup.sh verified the 3dcodeverse first on PATH instead of the --python interpreter")
+ assert "doctor" in proc.stdout
+
+
+def test_setup_names_the_remedy_when_the_interpreter_has_no_pip(tmp_path) -> None:
+ """PORT-7: on a stock Debian/Ubuntu box `/usr/bin/python3` ships without pip and is
+ PEP 668 marked, so the primary documented install path passed the whole prerequisite
+ block and then aborted on one unexplained line, `/usr/bin/python3: No module named
+ pip`, exit 1. setup.sh already die()s with actionable text for a missing python,
+ git, npm and package-lock.json; pip was the gap in its own contract."""
+ import sys
+
+ # a stand-in that answers the version probes but refuses `-m pip`, like a distro python3
+ nopip = tmp_path / "python-nopip"
+ nopip.write_text(
+ "#!/bin/sh\n"
+ 'for a in "$@"; do [ "$a" = "pip" ] && { echo "$0: No module named pip" >&2; exit 1; }; done\n'
+ f'exec {sys.executable} "$@"\n')
+ nopip.chmod(0o755)
+
+ proc = subprocess.run(["bash", str(SETUP), "--python", str(nopip), "--no-node", "--no-chrome", "--no-doctor"],
+ capture_output=True, text=True, timeout=300)
+ out = proc.stdout + proc.stderr
+ assert proc.returncode != 0, "a python that cannot pip must not look like a successful install"
+ assert "has no pip" in out, f"the bare ModuleNotFoundError is not an explanation:\n{out}"
+ assert "-m venv" in out and "python3-venv" in out, f"no actionable remedy in:\n{out}"
+
+
+def test_install_docs_list_pip_and_venv_as_prerequisites() -> None:
+ """The §2.2 table listed python/git/node/blender/ffmpeg but never pip or venv, and
+ §3 called a virtualenv "recommended but not required" — untrue on the OS §2.1 names."""
+ text = INSTALL.read_text()
+ assert "python3-venv" in text and "EXTERNALLY-MANAGED" in text
+ assert "pip + venv" in text, "the requirements table must name pip and venv"