Skip to content

Commit b5f2610

Browse files
Merge pull request #477 from lorenzwalthert/python-3.10
Use python 3.10 by default for conda envs
2 parents 577a838 + 7f68319 commit b5f2610

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

R/exec.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,10 @@ path_derive_precommit_exec_conda_impl <- function(conda_env) {
208208
ls <- reticulate::conda_list()
209209
path_reticulate <- fs::path_dir(ls[ls$name == conda_env, "python"][1])
210210
derived <- fs::path(
211+
# if windows, this is r-precommit, otherwise,
212+
# it's r-precommit/env and use just base directory
211213
path_reticulate,
214+
# if windows, append Scripts/
212215
ifelse(is_windows(), "Scripts", ""),
213216
precommit_executable_file()
214217
)

R/install.R

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,25 @@ install_precommit <- function(force = FALSE) {
5555
#' @keywords internal
5656
install_impl <- function() {
5757
if (!"r-precommit" %in% reticulate::conda_list()$name) {
58-
reticulate::conda_create("r-precommit")
58+
reticulate::conda_create("r-precommit", python_version = "3.11")
5959
}
6060
reticulate::conda_install("r-precommit", packages = "pre-commit")
61+
if (path_derive_precommit_exec_conda() == "") {
62+
base_dir <- grep(
63+
"r-precommit", gsub("r-precommit.*", "r-precommit", reticulate::conda_list()$python, ),
64+
value = TRUE
65+
)[1]
66+
rlang::abort(c(
67+
paste0(
68+
"Please open an issue on https://github.com/lorenzwalthert/precommit and ",
69+
"report the below:\nFailed to install pre-commit in a location known to R ",
70+
"precommit. Here are candidates from the conda root (",
71+
base_dir,
72+
"):"
73+
),
74+
list.files(base_dir, pattern = "pre-commit", recursive = TRUE)
75+
))
76+
}
6177
}
6278

6379
#' Updates pre-commit on your system with conda

tests/testthat/test-conda.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ if (!on_cran()) {
192192
expect_match(version_precommit(), "[0-9]+\\.[0-9]+\\.[0-9]+")
193193
} else {
194194
uninstall_precommit(scope = "user", ask = "none", root = ".")
195-
version <- "2.10.0"
195+
version <- "3.3.2" # TODO make this automaticly the last version
196196
reticulate::conda_install("r-precommit", paste0("pre-commit==", version))
197197
expect_equal(version_precommit(), version)
198+
skip_on_os("windows")
198199
expect_invisible(update_precommit(), 0)
199200
expect_false(version_precommit() == version)
200201
}

0 commit comments

Comments
 (0)