diff --git a/inst/tutorials/introduction-to-python/tutorial.Rmd b/inst/tutorials/introduction-to-python/tutorial.Rmd index aa94695..e55fc3c 100644 --- a/inst/tutorials/introduction-to-python/tutorial.Rmd +++ b/inst/tutorials/introduction-to-python/tutorial.Rmd @@ -23,23 +23,13 @@ description: Tutorial for introducing students to the Python language. # Don't let reticulate auto-pick some random Python Sys.setenv(RETICULATE_AUTOCONFIGURE = "FALSE") -# ---- Safe CRAN mirror + interactive-only installs ---- -# DK: Why the if clause here? - -if (is.null(getOption("repos")["CRAN"]) || !nzchar(getOption("repos")["CRAN"])) { - options(repos = c(CRAN = "https://cloud.r-project.org")) -} - -# DK: What happens if all the packages are installed? - -# Does interactive produce false here? And therefore no installs are ever done? Need to test that this works by removing some of the packages and running it. Do we need this section at all? - +# ---- interactive-only installs ---- needed <- c("learnr", "tutorial.helpers", "knitr", "reticulate") to_install <- setdiff(needed, rownames(installed.packages())) if (interactive() && length(to_install)) { install.packages(to_install, quiet = TRUE) } - +# SU: for the above im thinking of just taking it out and moving knitr and reticulate out of suggests and into imports in the description file to, which presumably do the same thing as above library(learnr) library(tutorial.helpers) library(knitr) @@ -50,15 +40,15 @@ learnr::tutorial_options( exercise.timelimit = 60, exercise.startover = TRUE ) - +## CI stuff to check if the tutorial is being run in github actions and R CMD Check, because then the check wil fail because it cant run python packages or modify the env, like the venv # ---- Environment flags ---- is_windows <- identical(.Platform$OS.type, "windows") # Do we need in_ci? What does it mean? in_ci <- identical(tolower(Sys.getenv("CI")), "true") || - identical(tolower(Sys.getenv("R_CMD_CHECK")), "true") || - !interactive() + identical(tolower(Sys.getenv("R_CMD_CHECK")), "true") + venv <- ".venv" py_bin <- if (is_windows) file.path(venv, "Scripts", "python.exe") else file.path(venv, "bin", "python")