Provisions a project-local Python environment via pyro (writing a
deckifyr dependency group to the calling project's pyproject.toml,
per deckifyr-specification.md section 5.2) and scaffolds
design.yaml/layouts.yaml/presentation.yaml into directory –
from the bundled minimal example by default, or from a template
source (issue #34) when from_dir/from_repo is given.
Usage
initialize_deck_project(
directory = ".",
force = FALSE,
from_dir = NULL,
from_repo = NULL,
ref = NULL,
subdir = NULL,
type = NULL,
python_env = getOption("deckifyr.python_env")
)Arguments
- directory
Target directory. Defaults to the current directory.
- force
Overwrite existing files in
directory. DefaultFALSE.- from_dir
Use a local directory as the template source instead of the bundled minimal example. Mutually exclusive with
from_repo.- from_repo
Fetch a git repo as the template source:
"[host/]owner/repo[/subdir][@ref]"shorthand (host defaults to github.com – an explicit host is how GitHub Enterprise is supported) or a full URL. Requiresgiton PATH. Mutually exclusive withfrom_dir.- ref
Branch/tag/SHA to check out. Only valid with
from_repo; overrides any@refembedded in its shorthand.- subdir
Subdirectory of the resolved repo to use as the template source. Only valid with
from_repo; overrides any subdirectory embedded in its shorthand.- type
Template name under a source's
templates/<name>/structure. Only valid alongsidefrom_dir/from_repo.- python_env
Path to an existing Python environment (a venv, or a project directory holding a
.venv) withpython-pptx,pydantic,pyyamlandpillow. It is verified and used as it is: pyro and uv are skipped, nothing is installed andpyproject.tomlis not touched. Defaults togetOption("deckifyr.python_env"), then theDECKIFYR_PYTHON_ENVenvironment variable. Every deckifyr function (deck_build(),deck_serve(), ...) uses the same setting, so set the option in the project's.Rprofileas well.
Details
A template source is either "flat" (a directory with its own
presentation.yaml, whose design/layouts files are duplicated
under their original names and paired with a freshly generated,
empty-slide presentation.yaml – the "duplicate a prior project"
case) or "typed" (a directory with a templates/ subdirectory, each
holding its own named flat template – select one with type; its
presentation.yaml is copied verbatim as a real minimal starter,
not emptied).
Either way, the local files those YAML files reference are copied to
the same relative paths: the design's slide.background_image, each
layout element's source (images, tables, Quarto fragments) and a
typed source's build.reportifyr.standard_footnotes. Other files in
the source (a README, an unreferenced image) are not copied. A
reference that is missing, absolute, uses .., goes through a
symlink or leaves the source is not copied and is reported as a
warning instead.
Offline mode
Offline mode is on when options(deckifyr.offline = TRUE),
DECKIFYR_OFFLINE=1 or uv's own UV_OFFLINE=1 is set, and nothing in
deckifyr then reaches the network:
deck_validate(),deck_build(),deck_preview(),deck_serve()and the other wrappers runuv run --no-sync, withUV_OFFLINE,UV_NO_INDEXandUV_PYTHON_DOWNLOADS=neverset, so a stale lock is used as it is instead of being re-locked and synced against the index.from_repois refused (clone the repository yourself while you have access and pass the checkout asfrom_dir), here and indeckifyr init --from-repo.Provisioning the environment here runs with
UV_OFFLINE=1(uv's cache only) and stops with a message, rather than letting pyro download it, whenuvis not installed.
Alternatively, python_env skips uv altogether.
Python packages
The deckifyr dependency group written to pyproject.toml includes the
packages behind the web extra (fastapi, uvicorn, for deck_serve())
and the preview extra (pymupdf, for deck_preview() and
build.previews), so both work after a plain initialization. Parquet table
sources need pyarrow, which is not added; add it to the group if you use
them. An existing group is merged, so re-running this adds what is missing.
Examples
if (FALSE) { # \dontrun{
# Scaffold a new project into a scratch directory (this mutates the
# calling project's pyproject.toml and provisions a Python/uv
# environment -- run it somewhere disposable, not the current project).
project_dir <- file.path(tempdir(), "my-deck")
initialize_deck_project(project_dir)
# Scaffold from an org-standard design/layouts repo instead, pinned
# to a tag, selecting the "quarterly-review" template type.
initialize_deck_project(
project_dir,
from_repo = "acme-org/deck-templates@v2",
type = "quarterly-review"
)
} # }
