Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions shiny/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,20 @@ def resolve_app(app: str, app_dir: Optional[str]) -> tuple[str, Optional[str]]:
attr = "app"

if is_file(module):
# Before checking module path, resolve it relative to app_dir if provided
module_path = module if app_dir is None else os.path.join(app_dir, module)
# TODO: We should probably be using some kind of loader
# TODO: I don't like that we exit here, if we ever export this it would be bad;
# but also printing a massive stack trace for a `shiny run badpath` is way
# unfriendly. We should probably throw a custom error that the shiny run
# entrypoint knows not to print the stack trace for.
if not os.path.exists(module):
sys.stderr.write(f"Error: {module} not found\n")
if not os.path.exists(module_path):
sys.stderr.write(f"Error: {module_path} not found\n")
sys.exit(1)
if not os.path.isfile(module):
sys.stderr.write(f"Error: {module} is not a file\n")
if not os.path.isfile(module_path):
sys.stderr.write(f"Error: {module_path} is not a file\n")
sys.exit(1)
dirname, filename = os.path.split(module)
dirname, filename = os.path.split(module_path)
module = filename[:-3] if filename.endswith(".py") else filename
app_dir = dirname

Expand Down