py

package
v0.2.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 19 Imported by: 1

Documentation

Overview

`py` package provides functions for working with Python.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PipFreeze added in v0.2.12

func PipFreeze() ([]string, error)

PipFreeze returns the lines produced by `uv pip freeze --python <pyPath>` (one line per package, e.g. package==version).

func PipInstall

func PipInstall(dep string) error

Install dependencies using uv pip

func PipList added in v0.2.12

func PipList() (map[string]string, error)

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 PipUninstall

func PipUninstall(dep string) error

Uninstall dependencies using uv pip

func ReinstallPyEnv added in v0.2.6

func ReinstallPyEnv() error

reinstall the Python environment

func RunCode

func RunCode(out any, code string) error

Run the Python code and bind the result to the provided struct pointer.

func RunCodeContext added in v0.2.12

func RunCodeContext(ctx context.Context, out any, code string) error

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

func RunCodeWithTimeout(timeout time.Duration, out any, code string) error

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

func RunCodef(out any, code string, args ...any) error

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

func RunCodefContext(ctx context.Context, out any, code string, args ...any) error

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

func RunFile(out any, filePath string) error

Run the Python file and bind the result to the provided struct pointer.

func RunFileContext added in v0.2.12

func RunFileContext(ctx context.Context, out any, filePath string) error

Run the Python file and bind the result to the provided struct pointer, with context.

func RunFilef added in v0.1.5

func RunFilef(out any, filePath string, args ...any) error

Run the Python file 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 RunFilefContext added in v0.2.12

func RunFilefContext(ctx context.Context, out any, filePath string, args ...any) error

Run the Python file with the given Golang variables and bind the result to the provided struct pointer, with context.

Types

This section is empty.

Directories

Path Synopsis
internal
ipc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL