Skip to content

AddUvicornApp doesn't use uvicorn from the virtual environment #545

Closed
@dluc

Description

@dluc

Describe the bug

Trying to launch a python service from Aspire using AddUvicornApp(), the launch fails with:

ModuleNotFoundError: No module named 'redis'

When I launch the python service manually, using poetry run uvicorn app.main:app everything works fine instead.

I found that the different behavior is because AddUvicornApp uses uvicorn (and python) from the host, rather than the one inside .venv:

Manual => poetry run uvicorn app.main:app => Ok
AddUvicornApp => uvicorn app.main:app => Fail

Could you change the implementation to allow using uvicorn from the virtual env (.venv dir)?

Regression

No response

Steps to reproduce

Create app with Poetry, add a dependency missing in the host, integrate the service using `AddUvicornApp`. The app crashes.

Expected behavior

AddUvicornApp should leverage uvicorn from the app .venv folder

Screenshots

No response

IDE and version

Other

IDE version

CLI

Nuget packages

Aspire.Hosting.AppHost 9.1.0
CommunityToolkit.Aspire.Hosting.Python.Extensions 9.2.1

Additional context

No response

Help us help you

No, just wanted to report this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions