@@ -56,10 +56,9 @@ cache_engines$.get = cache_engines$get
5656cache_engines $ get = function (name , ... ) {
5757 if (missing(name )) {
5858 cache_engines $ .get(... )
59- } else if (! identical(name , ' python' ) || ! isFALSE(options $ python.reticulate )) {
60- cache_engines $ .get(name , ... )
6159 } else {
62- NULL
60+ cache_importer = cache_engines $ .get(name , ... )
61+ cache_importer()
6362 }
6463}
6564
@@ -288,6 +287,17 @@ eng_python = function(options) {
288287 }
289288}
290289
290+ cache_eng_python = function () {
291+ # TODO: change this hack to reticulate::cache_eng_python after
292+ # https://github.com/rstudio/reticulate/pull/1210 is merged and released
293+ if (! isFALSE(options $ python.reticulate ) &&
294+ ' cache_eng_python' %in% ls(asNamespace(' reticulate' ))) {
295+ getFromNamespace(' cache_eng_python' , ' reticulate' )
296+ } else {
297+ NULL
298+ }
299+ }
300+
291301# # Java
292302# e.g. see http://cran.rstudio.com/package=jvmr
293303
@@ -925,11 +935,7 @@ knit_engines$set(
925935 verbatim = eng_verbatim
926936)
927937
928- # TODO: change this hack to reticulate::cache_eng_python after
929- # https://github.com/rstudio/reticulate/pull/1210 is merged and released
930- if (' cache_eng_python' %in% ls(asNamespace(' reticulate' ))) {
931- cache_engines $ set(python = getFromNamespace(' cache_eng_python' , ' reticulate' ))
932- }
938+ cache_engines $ set(python = cache_eng_python )
933939
934940get_engine = function (name ) {
935941 fun = knit_engines $ get(name )
0 commit comments