You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add WithPythonUvEnvironment to Python extension builder in Aspire.Hosting.Python #11934
Is your feature request related to a problem? Please describe the problem.
The Aspire.Hosting.Python package needs a way of adding a UV-managed virtual environment with dependencies to the PythonAppResource.
This can be done with an extension method to the builder patterns in PythonAppResourceBuilderExtensions called WithPythonUvEnvironment.
Describe the solution you'd like
The method should take any PythonAppResource and attach a child resource which runs the uv sync command in the working directory of the Python app to ensure that the virtual environment exists.
This new resource runs uv sync in the working directory of the Python App Resource for which it was attached. This uv sync command is done via the existing Executable Resource infrastructure.
Behaviours:
The name of this new resource is the python app resource name with -uv-environment suffixed, i.e. $"{builder.Resource.Name}-uv-environment
This new resource is a new standalone resource class, PythonUvEnvironmentResource
This new UV resource adds the Python app resource as a parent and sets a WaitForCompletion relationship to the parent so that the uv sync command must complete successfully before the PythonAppResource can be started. This ensure that the virtual environment exists and the dependencies are installed before the Python app is started.
If the uv sync command fails, it should fail the resource and the parent Python App resource will fail to start.
Activity