Instead of renaming app.py (or whatever.py) to main.py, use proper packaging and entrypoints to execute code.
Here is a simple example in Poetry of how to generate a proper executable using entrypoints in pyproject.toml:
[tool.poetry.scripts]
dummy-project = "dummy_project.app:app"