Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

PythonAppResource

Handle
📦 Aspire.Hosting.Python v17.0.0
type PythonAppResource interface {
IComputeResource
IContainerFilesDestinationResource
Resource
ResourceWithArgs
ResourceWithEndpoints
ResourceWithEnvironment
ResourceWithWaitSupport
}

Methods

methodWithDebuggingbuilder
Enables debugging support for the Python application.
WithDebugging() PythonAppResource
PythonAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithEntrypointbuilder
Configures the entrypoint for the Python application.
WithEntrypoint(
entrypointType EntrypointType,
entrypoint string,
) PythonAppResource
entrypointTypeEntrypointTypeThe type of entrypoint (Script, Module, or Executable).
entrypointstringThe entrypoint value (script path, module name, or executable name).
PythonAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithPipbuilder
Configures the Python resource to use pip as the package manager and optionally installs packages before the application starts.
WithPip(options ...*WithPipOptions) PythonAppResource
options...*WithPipOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithPipOptions argument.

Install*boolWhen true (default), automatically installs packages before the application starts. When false, only sets the package manager annotation without creating an installer resource.
InstallArgs[]stringThe command-line arguments passed to pip install command.
PythonAppResource

The resource builder.

Returns a handle; failures surface later via Err().

methodWithUvbuilder
Adds a UV environment setup task to ensure the virtual environment exists before running the Python application.
WithUv(options ...*WithUvOptions) PythonAppResource
options...*WithUvOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithUvOptions argument.

Install*boolWhen true (default), automatically runs uv sync before the application starts. When false, only sets the package manager annotation without creating an installer resource.
Args[]stringOptional custom arguments to pass to the uv command. If not provided, defaults to ["sync"].
PythonAppResource

The resource builder.

Returns a handle; failures surface later via Err().

Configures a custom virtual environment path for the Python application.
WithVirtualEnvironment(
virtualEnvironmentPath string,
options ...*WithVirtualEnvironmentOptions,
) PythonAppResource
virtualEnvironmentPathstringThe path to the virtual environment. Can be absolute or relative to the app directory. When relative, it is resolved from the working directory of the Python application. Common values include ".venv", "venv", or "myenv".
options...*WithVirtualEnvironmentOptionsOptional settings, described under Options.

Optional parameters are passed in a trailing options ...*WithVirtualEnvironmentOptions argument.

CreateIfNotExists*boolWhether to automatically create the virtual environment if it doesn't exist. Defaults to true. Set to false to disable automatic venv creation (the venv must already exist).
PythonAppResource

The resource builder.

Returns a handle; failures surface later via Err().