Skip to content

For Express, emit message if need to upgrade rsconnect-python #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ install_requires =
linkify-it-py>=1.0
appdirs>=1.4.4
asgiref>=3.5.2
packaging>=20.9
watchfiles>=0.18.0;platform_system!="Emscripten"
questionary>=2.0.0;platform_system!="Emscripten"
# This is needed to address a DoS issue. In the future, when we are able to upgrade
Expand Down
28 changes: 28 additions & 0 deletions shiny/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ def run_app(
# is "shiny.express.app:_2f_path_2f_to_2f_app_2e_py".
app = "shiny.express.app:" + escape_to_var_name(str(app_path))
app_dir = str(app_path.parent)

# Express apps need min version of rsconnect-python to deploy correctly.
_verify_rsconnect_version()
else:
app, app_dir = resolve_app(app, app_dir)

Expand Down Expand Up @@ -626,3 +629,28 @@ class ReloadArgs(TypedDict):
reload_includes: NotRequired[list[str]]
reload_excludes: NotRequired[list[str]]
reload_dirs: NotRequired[list[str]]


# Check that the version of rsconnect supports Shiny Express; can be removed in the
# future once this version of rsconnect is widely used. The dependency on "packaging"
# can also be removed then, because it is only used here. (Added 2024-03)
def _verify_rsconnect_version() -> None:
PACKAGE_NAME = "rsconnect-python"
MIN_VERSION = "1.22.0"

from importlib.metadata import PackageNotFoundError, version

from packaging.version import parse

try:
installed_version = parse(version(PACKAGE_NAME))
required_version = parse(MIN_VERSION)
if installed_version < required_version:
print(
f"Warning: rsconnect-python {installed_version} is installed, but it does not support deploying Shiny Express applications. "
f"Please upgrade to at least version {MIN_VERSION}. "
"If you are using pip, you can run `pip install --upgrade rsconnect-python`",
file=sys.stderr,
)
except PackageNotFoundError:
pass