Skip to content

Reload=True fails when run from a venv module #1495

@pdc1

Description

@pdc1

Hello,

I have an app with a root-level app.py that does run(...) if __name__ == "__main__". So far so good.

I recently moved app.py into the app module so it was included in the packaging, but now the development-level run(...) doesn't work if reloader=True.

I am using poetry, so the app is running in a venv, if that matters.

> py -m libsearch.app
Running Bottle app in development mode
Routes registered: [<GET / -> libsearch.views:search_form>, <GET /tailwind.css -> libsearch.views:get_css>, <POST /results -> libsearch.views:search>]
[...]\pypoetry\Cache\virtualenvs\libsearch-vAUISaff-py3.11\Scripts\python.exe: No module named libsearch.__main__; 'libsearch' is a package and cannot be directly executed

If I set reloader=False it works as expected. There are easy workarounds (use the root-level app.py or set reloader=False) but this sure took a long time to debug!

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