Aspirerelease/17.0
Watch Aspire live streamsDocsTry Aspire

WithVirtualEnvironment

Method
📦 Aspire.Hosting.Python v17.0.0
func (PythonAppResource) WithVirtualEnvironment(
virtualEnvironmentPath string,
options ...*WithVirtualEnvironmentOptions,
) PythonAppResource

Signature

methodWithVirtualEnvironmentbuilder
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().

Applies to

This method applies to the following types: