Describe the bug
When a blacksheep app with a routes/ folder is installed via uv tool install, app = Application() crashes at import time, the app cannot start.
The expected behavior is the app starts normally when I call the binary installed via uv tool from anywhere.
Steps to reproduce
1. Minimal project files creation
mkdir -p repro/myapp/routes
cat > repro/pyproject.toml << 'EOF'
[project]
name = "myapp"
version = "0.1.0"
dependencies = ["blacksheep"]
[project.scripts]
myapp = "myapp.main:run"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
EOF
cat > repro/myapp/__init__.py << 'EOF'
EOF
cat > repro/myapp/main.py << 'EOF'
from blacksheep import Application
app = Application()
def run():
pass
EOF
touch repro/myapp/routes/__init__.py
cat > repro/myapp/routes/home.py << 'EOF'
from blacksheep import get
@get("/")
async def home():
return "Hello"
EOF
2. Install it as a tool
cd repro && uv tool install .
3. Run the binary from somewhere, let say in home ~ folder
And what I got:
Traceback (most recent call last):
File "/home/vietspaceanh/.local/bin/myapp", line 4, in <module>
from myapp.main import run
File "/home/vietspaceanh/.local/share/uv/tools/myapp/lib/python3.12/site-packages/myapp/main.py", line 3, in <module>
app = Application()
^^^^^^^^^^^^^
File "/home/vietspaceanh/.local/share/uv/tools/myapp/lib/python3.12/site-packages/blacksheep/server/application.py", line 215, in __init__
_auto_import_routes(parent_file)
File "/home/vietspaceanh/.local/share/uv/tools/myapp/lib/python3.12/site-packages/blacksheep/server/application.py", line 1016, in _auto_import_routes
_auto_import(parent_file, "routes")
File "/home/vietspaceanh/.local/share/uv/tools/myapp/lib/python3.12/site-packages/blacksheep/server/application.py", line 1008, in _auto_import
import_child_modules(controllers_path)
File "/home/vietspaceanh/.local/share/uv/tools/myapp/lib/python3.12/site-packages/blacksheep/utils/meta.py", line 31, in import_child_modules
__import__(stripped_path + "." + module)
ModuleNotFoundError: No module named '.local'
Describe the bug
When a
blacksheepapp with aroutes/folder is installed viauv tool install,app = Application()crashes at import time, the app cannot start.The expected behavior is the app starts normally when I call the binary installed via
uv toolfrom anywhere.Steps to reproduce
1. Minimal project files creation
2. Install it as a tool
3. Run the binary from somewhere, let say in home
~folderAnd what I got: