Ran behavision-setup in a fresh Linux container: Python 3.12, nothing else, the release contents mounted read-only the way Program Files or a shared drive would be. It failed, and then it failed differently, and both failures would have been the client's first experience. 1. `pip install <folder>` makes setuptools write behavision.egg-info INTO the folder. The folder is read-only wherever a release is sensibly unzipped, so: "could not create 'behavision.egg-info': Read-only file system". The release now ships a wheel - pure Python, buildable anywhere, nothing to build on the shop PC, and pip never touches the unzipped folder. Source stays as a fallback and is copied somewhere writable first. 2. The engine's paths.py knows two worlds - frozen (ProgramData) and a checkout (the repo root) - and a pip-installed engine is neither. It resolved its state root to site-packages: database there, camera list there, and its generated API credential in a folder the app never reads, while the app looked in ProgramData. Every call would be 401 on a stock install, with nothing in either log saying why. The same disease as the Mac checkout two days ago, now in production shape. engine.ChildEnv is the one place the engine's environment is built, used by the desktop app, the headless agent and the installer's own smoke test. It passes BEHAVISION_DATA_DIR = this process's state root, which paths.py honours ahead of every other rule, so the two halves agree by construction however the engine was installed. It also seeds config/default.yaml into the state root: a package in site-packages has no config beside it to seed from. Re-run on the same clean container: seven steps, all pass, models downloaded, engine started and answered, and its data/ landed beside agent.json - not in site-packages. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KGcjxF1cNLcuwc3DAPcnfj
42 lines
1.7 KiB
Go
42 lines
1.7 KiB
Go
package engine
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/loyaly/behavision-agent/pkg/paths"
|
|
)
|
|
|
|
// ChildEnv is the environment the engine is launched with, wherever it is
|
|
// launched from - the desktop app and the headless agent both go through
|
|
// here, so a third caller cannot get it half right.
|
|
//
|
|
// The line that matters is BEHAVISION_DATA_DIR.
|
|
//
|
|
// The engine's paths.py knows two worlds: frozen with PyInstaller, where state
|
|
// lives under ProgramData, and a checkout, where everything sits in the repo
|
|
// root. An engine installed from source into a virtual environment is neither.
|
|
// Left to itself it resolves its state root to site-packages - writes its
|
|
// database and camera list there, and generates its API credential into a
|
|
// folder this process never reads - while this process resolves the same
|
|
// state root to ProgramData. The two halves then disagree about where
|
|
// everything lives, and every call to the engine is 401 on a stock install,
|
|
// with nothing in either log saying why. Seen twice: once on a Mac checkout
|
|
// (the app in ~/Library, the engine in the repo) and once in a clean Linux
|
|
// container running the installer.
|
|
//
|
|
// Telling the engine where THIS process keeps state makes the two agree by
|
|
// construction, however the engine was installed. paths.py honours the
|
|
// override ahead of every other rule it has.
|
|
//
|
|
// hookURL is where the engine posts detections; empty is allowed and means
|
|
// the bridge has not started, which the engine treats as "no webhook".
|
|
func ChildEnv(hookURL string) []string {
|
|
env := append(os.Environ(),
|
|
"BEHAVISION_DATA_DIR="+paths.StateRoot(),
|
|
)
|
|
if hookURL != "" {
|
|
env = append(env, "BEHAVISION_WEBHOOK_URL="+hookURL)
|
|
}
|
|
return env
|
|
}
|