application

package
v0.0.0-...-f0b372e Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0 Imports: 22 Imported by: 1

Documentation

Overview

Package application contains the base framework to build `vpython` binaries for different python versions or bundles.

Index

Constants

View Source
const (
	// VirtualEnvRootENV is an environment variable that, if set, will be used
	// as the default VirtualEnv root.
	//
	// This value overrides the default (~/.vpython-root), but can be overridden
	// by the "-vpython-root" flag.
	//
	// Like "-vpython-root", if this value is present but empty, a tempdir will be
	// used for the VirtualEnv root.
	VirtualEnvRootENV = "VPYTHON_VIRTUALENV_ROOT"

	// DefaultSpecENV is an environment variable that, if set, will be used as the
	// default VirtualEnv spec file if none is provided or found through probing.
	DefaultSpecENV = "VPYTHON_DEFAULT_SPEC"

	// LogTraceENV is an environment variable that, if set, will set the default
	// log level to Debug.
	//
	// This is useful when debugging scripts that invoke "vpython" internally,
	// where adding the "-vpython-log-level" flag is not straightforward. The
	// flag is preferred when possible.
	LogTraceENV = "VPYTHON_LOG_TRACE"

	// BypassENV is an environment variable that is used to detect if we shouldn't
	// do any vpython stuff at all, but should instead directly invoke the next
	// `python` on PATH.
	BypassENV = "VPYTHON_BYPASS"

	// InterpreterENV is an environment variable that override the default
	// searching behaviour for the bundled interpreter. It should only be used
	// for testing and debugging purpose.
	InterpreterENV = "VPYTHON_INTERPRETER"

	// BypassSentinel must be the BypassENV value (verbatim) in order to trigger
	// vpython bypass.
	BypassSentinel = "manually managed python not supported by chrome operations"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	// PruneThreshold, if > 0, is the maximum age of a VirtualEnv before it
	// becomes candidate for pruning. If <= 0, no pruning will be performed.
	PruneThreshold time.Duration

	// MaxPrunesPerSweep, if > 0, is the maximum number of VirtualEnv that should
	// be pruned passively. If <= 0, no limit will be applied.
	MaxPrunesPerSweep int

	// Bypass, if true, instructs vpython to completely bypass VirtualEnv
	// bootstrapping and execute with the local system interpreter.
	Bypass bool

	// Loglevel is used to configure the default logger set in the context.
	LogLevel logging.Level

	// Help, if true, displays the usage from both vpython and python
	Help  bool
	Usage string

	// Path to environment specification file to load. Default probes for one.
	SpecPath string

	// Path to default specification file to load if no specification is found.
	DefaultSpecPath string

	// Pattern of default specification file. If empty, uses .vpython3.
	DefaultSpecPattern string

	// Path to virtual environment root directory.
	// If explicitly set to empty string, a temporary directory will be used and
	// cleaned up on completion.
	VpythonRoot string

	// Path to cipd cache directory.
	CIPDCacheDir string

	// Tool mode, if it's not empty, vpython will execute the tool instead of
	// python.
	ToolMode string

	// WorkDir is the Python working directory. If empty, the current working
	// directory will be used.
	WorkDir string

	// InterpreterPath is the path to the python interpreter cipd package. If
	// empty, uses the bundled python from paths relative to the vpython binary.
	InterpreterPath string

	Environments []string
	Arguments    []string

	VpythonSpec       *vpythonAPI.Spec
	PythonCommandLine *python.CommandLine
	PythonExecutable  string
	// contains filtered or unexported fields
}

Application contains the basic configuration for the application framework.

func (*Application) BuildVENV

BuildVENV builds the derivation for the venv and updates applications' PythonExecutable to the python binary in the venv.

func (*Application) ExecutePython

func (a *Application) ExecutePython(ctx context.Context) error

ExecutePython executes the python with arguments. It uses execve on linux and simulates execve's behavior on windows.

func (*Application) GetExecCommand

func (a *Application) GetExecCommand() *exec.Cmd

GetExecCommand returns the equivalent command when python is executed using ExecutePython.

func (*Application) Initialize

func (a *Application) Initialize(ctx context.Context) context.Context

Initialize logger first to make it available for all steps after.

func (*Application) LoadSpec

func (a *Application) LoadSpec(ctx context.Context) error

LoadSpec searches and load vpython spec from path or script.

func (*Application) ParseArgs

func (a *Application) ParseArgs(ctx context.Context) (err error)

ParseArgs parses arguments from command line.

func (*Application) ParseEnvs

func (a *Application) ParseEnvs(ctx context.Context) (err error)

ParseEnvs parses arguments from environment variables.

func (*Application) SetLogLevel

func (a *Application) SetLogLevel(ctx context.Context) context.Context

SetLogLevel sets log level to the provided context.

Jump to

Keyboard shortcuts

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