Documentation
¶
Overview ¶
`py` package provides functions for working with Python.
Index ¶
- func PipFreeze() ([]string, error)
- func PipInstall(dep string) error
- func PipList() (map[string]string, error)
- func PipUninstall(dep string) error
- func ReinstallPyEnv() error
- func RunCode(out any, code string) error
- func RunCodeContext(ctx context.Context, out any, code string) error
- func RunCodeWithTimeout(timeout time.Duration, out any, code string) error
- func RunCodef(out any, code string, args ...any) error
- func RunCodefContext(ctx context.Context, out any, code string, args ...any) error
- func RunFile(out any, filePath string) error
- func RunFileContext(ctx context.Context, out any, filePath string) error
- func RunFilef(out any, filePath string, args ...any) error
- func RunFilefContext(ctx context.Context, out any, filePath string, args ...any) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PipFreeze ¶ added in v0.2.12
PipFreeze returns the lines produced by `uv pip freeze --python <pyPath>` (one line per package, e.g. package==version).
func PipList ¶ added in v0.2.12
PipList returns a map of installed package names to their versions for the Python environment managed by uv. It runs `uv pip list --format=json --python <pyPath>` and parses the JSON output.
func RunCodeContext ¶ added in v0.2.12
Run the Python code using the provided context. If the context is canceled the underlying Python process will be killed and the function will return the context error (e.g., context.Canceled or context.DeadlineExceeded).
func RunCodeWithTimeout ¶ added in v0.2.12
Run the Python code with a timeout. This is a convenience wrapper that creates a context with timeout and runs the code. If the timeout occurs it returns context.DeadlineExceeded (i.e., ctx.Err()).
func RunCodef ¶
Run the Python code with the given Golang variables and bind the result to the provided struct pointer. The codeTemplate should use $v1, $v2, etc. placeholders for variable substitution.
func RunCodefContext ¶ added in v0.2.12
Run the Python code with the given Golang variables and a Context. The codeTemplate should use $v1, $v2, etc. placeholders for variable substitution.
func RunFile ¶ added in v0.1.5
Run the Python file and bind the result to the provided struct pointer.
func RunFileContext ¶ added in v0.2.12
Run the Python file and bind the result to the provided struct pointer, with context.
Types ¶
This section is empty.