@@ -288,6 +288,9 @@ def run_app(
288288 # is "shiny.express.app:_2f_path_2f_to_2f_app_2e_py".
289289 app = "shiny.express.app:" + escape_to_var_name (str (app_path ))
290290 app_dir = str (app_path .parent )
291+
292+ # Express apps need min version of rsconnect-python to deploy correctly.
293+ _verify_rsconnect_version ()
291294 else :
292295 app , app_dir = resolve_app (app , app_dir )
293296
@@ -626,3 +629,28 @@ class ReloadArgs(TypedDict):
626629 reload_includes : NotRequired [list [str ]]
627630 reload_excludes : NotRequired [list [str ]]
628631 reload_dirs : NotRequired [list [str ]]
632+
633+
634+ # Check that the version of rsconnect supports Shiny Express; can be removed in the
635+ # future once this version of rsconnect is widely used. The dependency on "packaging"
636+ # can also be removed then, because it is only used here. (Added 2024-03)
637+ def _verify_rsconnect_version () -> None :
638+ PACKAGE_NAME = "rsconnect-python"
639+ MIN_VERSION = "1.22.0"
640+
641+ from importlib .metadata import PackageNotFoundError , version
642+
643+ from packaging .version import parse
644+
645+ try :
646+ installed_version = parse (version (PACKAGE_NAME ))
647+ required_version = parse (MIN_VERSION )
648+ if installed_version < required_version :
649+ print (
650+ f"Warning: rsconnect-python { installed_version } is installed, but it does not support deploying Shiny Express applications. "
651+ f"Please upgrade to at least version { MIN_VERSION } . "
652+ "If you are using pip, you can run `pip install --upgrade rsconnect-python`" ,
653+ file = sys .stderr ,
654+ )
655+ except PackageNotFoundError :
656+ pass
0 commit comments