Skip to content

Commit

Permalink
Merge pull request #370 from rstudio/fix-windows-run
Browse files Browse the repository at this point in the history
  • Loading branch information
wch authored Nov 3, 2022
2 parents 377f712 + 11181f0 commit c9bae9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Closed #240, #330: Fixed live examples with additional files. (#340)

* Fixed `shiny run` handling on Windows of absolute paths with drive letter, as in `shiny run c:/myapp/app.py`. (#370)

### Other changes


Expand Down
10 changes: 9 additions & 1 deletion shiny/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import importlib
import importlib.util
import os
import platform
import re
import shutil
import sys
import types
Expand Down Expand Up @@ -301,7 +303,13 @@ def resolve_app(app: str, app_dir: Optional[str]) -> Tuple[str, Optional[str]]:
# - directory (look for app:app inside of it)
# - A module name (look for :app) inside of it

module, _, attr = app.partition(":")
if platform.system() == "Windows" and re.match("^[a-zA-Z]:[/\\\\]", app):
# On Windows, need special handling of ':' in some cases, like these:
# shiny run c:/Users/username/Documents/myapp/app.py
# shiny run c:\Users\username\Documents\myapp\app.py
module, attr = app, ""
else:
module, _, attr = app.partition(":")
if not module:
raise ImportError("The APP parameter cannot start with ':'.")
if not attr:
Expand Down

0 comments on commit c9bae9f

Please sign in to comment.