Skip to content
Open
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
5 changes: 5 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- R dependency detection from an `renv.lock` file. When deploying Python content
that also uses R (e.g. `rpy2`), rsconnect-python reads the lockfile and adds the
R version and packages to the manifest so Posit Connect can restore the R
library. The lockfile location honors the `RENV_PATHS_LOCKFILE` environment
variable. Use `--exclude-renv` to opt out.
- `rsconnect quickstart` command for scaffolding a new Connect-ready project.
Supported types: `streamlit`, `shiny`, `fastapi`, `api`, `flask`, `notebook`,
`voila`, `quarto`. Creates a uv-managed virtualenv and prints
Expand Down
33 changes: 33 additions & 0 deletions docs/deploying.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,39 @@ use Python version 3.11.5.
> The packages and package versions listed in `requirements.txt` must be
> compatible with the Python version you request.

#### R Dependencies (renv.lock)

Python content that also uses R (for example, an app that calls R through
[`rpy2`](https://rpy2.github.io/)) can declare its R package dependencies with an
[renv](https://rstudio.github.io/renv/) lockfile. When an `renv.lock` file is
found, rsconnect-python reads it and adds the R version and package list to the
generated `manifest.json`, so Posit Connect can restore the R library alongside
the Python environment. The lockfile is only parsed; R is never invoked.

Detection happens automatically whenever a lockfile is present. To deploy without
it, use the `--exclude-renv` option:

```bash
rsconnect deploy api --exclude-renv my-api/
```

By default the lockfile is read from `renv.lock` in the content directory. The
location can be overridden with the `RENV_PATHS_LOCKFILE` environment variable,
matching renv's own resolution: the value is used as given (a trailing slash is
treated as a directory, so `renv.lock` is appended), and a relative path is
resolved against the current working directory.

```bash
RENV_PATHS_LOCKFILE=/path/to/renv.lock rsconnect deploy api my-api/
```

> **Note**
> The lockfile must be generated by renv 1.1.0 or later, so it records the
> repositories used to resolve each package. rsconnect-python stops with an error
> if the lockfile is incompatible or a package cannot be resolved; use
> `--exclude-renv` to deploy without R dependencies. renv profiles are not
> supported; only `RENV_PATHS_LOCKFILE` and the default location are consulted.

### Creating a Manifest for Future Deployment

You can create a `manifest.json` file for an API or application, then use that
Expand Down
4 changes: 4 additions & 0 deletions rsconnect/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
read_manifest_file,
)
from .environment import Environment
from .environment_r import REnvironment
from .exception import RSConnectException
from .log import VERBOSE, logger
from .models import AppMode, AppModes
Expand Down Expand Up @@ -500,6 +501,7 @@ def create_quarto_deployment_bundle(
image: Optional[str] = None,
env_management_py: Optional[bool] = None,
env_management_r: Optional[bool] = None,
r_environment: Optional[REnvironment] = None,
) -> typing.IO[bytes]:
"""
Create an in-memory bundle, ready to deploy.
Expand All @@ -519,6 +521,7 @@ def create_quarto_deployment_bundle(
The server administrator is responsible for installing packages in the runtime environment. Default = None.
:param env_management_r: False prevents Connect from managing the R environment for this bundle.
The server administrator is responsible for installing packages in the runtime environment. Default = None.
:param r_environment: optional R dependencies detected from renv.lock to add to the manifest.
:return: the bundle.
"""
if app_mode is None:
Expand All @@ -534,6 +537,7 @@ def create_quarto_deployment_bundle(
image,
env_management_py,
env_management_r,
r_environment,
)


Expand Down
Loading
Loading