python

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandRunner

type CommandRunner func(ctx context.Context, name string, args ...string) ([]byte, error)

CommandRunner executes a command and returns its combined output.

type Detector

type Detector interface {
	Detect(ctx context.Context) (*Environment, error)
}

Detector defines the interface for detecting a Python environment.

type EnvLookup

type EnvLookup func(string) string

EnvLookup looks up an environment variable.

type Environment

type Environment struct {
	PythonPath    string // path to the python binary
	Prefix        string // sys.prefix
	SitePackages  string // site-packages directory
	PlatformTag   string // e.g., "macosx-14.0-arm64"
	PythonVersion string // e.g., "312"
	IsVirtualEnv  bool
}

Environment represents a detected Python environment.

type Option

type Option func(*Service)

Option configures a Service.

func WithCommandRunner

func WithCommandRunner(fn CommandRunner) Option

WithCommandRunner sets the command runner for executing external processes. Defaults to exec.CommandContext.

func WithEnvLookup

func WithEnvLookup(fn EnvLookup) Option

WithEnvLookup sets the function used to read environment variables. Defaults to os.Getenv.

func WithPythonBin

func WithPythonBin(bin string) Option

WithPythonBin sets the python binary path. Defaults to "python3".

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service detects the active Python environment by inspecting environment variables and running the python binary.

func New

func New(opts ...Option) *Service

New creates a new Python environment detector.

func (*Service) Detect

func (s *Service) Detect(ctx context.Context) (*Environment, error)

Detect detects the active Python environment. It first checks the VIRTUAL_ENV env var, then runs the python binary to determine prefix, site-packages path, platform tag, and version.

Jump to

Keyboard shortcuts

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