Skip to content

Commit 3c94997

Browse files
committed
perf: not compile .venv and .uv-cache
1 parent d9ed798 commit 3c94997

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

internal/core/local_runtime/setup_python_environment.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,21 @@ func (p *LocalPluginRuntime) preCompile(
464464
ctx, cancel := context.WithTimeout(baseCtx, 10*time.Minute)
465465
defer cancel()
466466

467+
const defaultExcludePattern = `\.venv|\.uv-cache`
468+
excludePattern := defaultExcludePattern
467469
compileArgs := []string{"-m", "compileall"}
468470
if p.appConfig.PythonCompileAllExtraArgs != "" {
469-
compileArgs = append(compileArgs, strings.Split(p.appConfig.PythonCompileAllExtraArgs, " ")...)
471+
extraArgs := strings.Fields(p.appConfig.PythonCompileAllExtraArgs)
472+
for i := 0; i < len(extraArgs); i++ {
473+
if extraArgs[i] == "-x" && i+1 < len(extraArgs) {
474+
excludePattern = defaultExcludePattern + "|" + extraArgs[i+1]
475+
i++
476+
} else {
477+
compileArgs = append(compileArgs, extraArgs[i])
478+
}
479+
}
470480
}
471-
compileArgs = append(compileArgs, ".")
481+
compileArgs = append(compileArgs, "-x", excludePattern, ".")
472482

473483
// pre-compile the plugin to avoid costly compilation on first invocation
474484
compileCmd := exec.CommandContext(ctx, pythonPath, compileArgs...)

0 commit comments

Comments
 (0)