• Stefy Lanza (nextime / spora )'s avatar
    longcat: the isolated Python 3.10 venv and its packaging (v0.2.30) · 7f7597ff
    Stefy Lanza (nextime / spora ) authored
    Step 1 of the LongCat-Video integration: provision the runtime. No engine code yet.
    
    LongCat is the strictest isolation in the tree — it pins Python 3.10, torch 2.6+cu124,
    transformers 4.41 and numpy 1.26 against the main venv's 3.13 / 2.11+cu130 / 5.x / 2.4,
    four simultaneous conflicts, plus opencv-python against the bundled opencv-contrib.
    Installing it into the main venv would walk transformers and numpy backwards and break
    the stack, the failure already recorded for parler-tts.
    
    Crucially, coderai cannot build this venv itself: every venv bootstrap in codai/ uses
    `sys.executable -m venv`, which is 3.13. The only 3.10 in the tree is the standalone
    interpreter hand-built for the lip-sync tools and bundled as py310/, so LongCat rides
    that same interpreter in a venv of its own (its torch differs, so they cannot share one).
    
    - requirements-longcat.txt: upstream's pins off the cu124 index. flash-attn is
      deliberately NOT pinned — it is a source build needing ninja and a CUDA toolchain, and
      upstream accepts xformers, which ships a wheel; longcat.attention = "flash" is the
      opt-in. streamlit (upstream's demo UI) is left out.
    - build_oci_image.sh: declares LONGCAT_VENV and bundles it. The py3.10 interpreter is now
      discovered from EITHER py3.10 venv's pyvenv.cfg — it was read only from the lip-sync
      one, so a host with LongCat and no lip-sync venv would have bundled a venv with no
      interpreter to run it.
    - Dockerfile.oci-venv: copies longcat_venv and the pyvenv.cfg/bin-symlink rewrite now
      loops over both venvs. A bundled venv still carries the build host's `home =`, so
      without that its bin/python points at an interpreter the image does not have.
    - smoke_test_services.sh: asserts 3.10 + torch 2.6 + transformers 4.41, not just that
      torch imports — a venv re-pointed at the WRONG interpreter passes a bare import while
      being useless.
    - LongcatConfig (enabled, service_url, venv, python, auto_build, host, port, gpu,
      attention, ready_timeout, extra_args, extra_env), attached to Config, serialised by
      save_config, reconstructed in load() and exposed/parsed by the admin settings API.
      auto_build ships OFF: it pulls torch 2.6 plus its CUDA runtime.
    
    16 tests. The config round-trip one caught a real hole: load() reconstructs each section
    explicitly, so without its line the operator could set LongCat up in the interface and
    lose it on the next restart.
    Co-Authored-By: 's avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    Claude-Session: https://claude.ai/code/session_0182DhR1eFNPQyGmDrpHbedY
    7f7597ff
test_longcat_packaging.py 6.33 KB