packages/python/src/quirks/README.md
Post-install fix-ups that run when specific Python packages are detected in the venv. Each quirk patches the build so a package works correctly on Vercel.
runQuirks() scans installed distributions in the venv's site-packages
(via scanDistributions from @vercel/python-analysis), then iterates
the quirk registry and calls run() for each quirk whose dependency
is present. Results are merged: env goes to the Lambda environment,
buildEnv to subsequent build steps, and alwaysBundlePackages
prevents the externalizer from splitting those packages out.
<package>.ts -- name the file after the PyPI distribution name
(e.g. prisma.ts for prisma).Quirk object with:
dependency -- the PyPI distribution name used for detection.runsBefore / runsAfter (optional) -- arrays of dependency names
that control execution order. runsBefore: ['X'] ensures this quirk
runs before X; runsAfter: ['X'] ensures it runs after X. Activated
quirks are topologically sorted using these edges (cycles are an error).run(ctx) -- receives venvPath, pythonEnv, and workPath;
returns QuirkResult.quirks array in index.ts.test/fixtures/.@vercel/python-runtime
or @vercel/python.VERCEL_RUNTIME_ENV_PATH_PREPEND prepends directories to
PATH at function startup.node_modules, etc.) before
returning.dist-info/RECORD for any files added inside site-packages so
the packaging system picks them up properly.