@@ -56,8 +56,8 @@ 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 , ... )
59+ } else if (! is.null( cache_importer <- cache_engines $ .get( name , ... ) )) {
60+ cache_importer( )
6161 } else {
6262 NULL
6363 }
@@ -288,6 +288,17 @@ eng_python = function(options) {
288288 }
289289}
290290
291+ cache_eng_python = function () {
292+ # TODO: change this hack to reticulate::cache_eng_python after
293+ # https://github.com/rstudio/reticulate/pull/1210 is merged and released
294+ if (! isFALSE(options $ python.reticulate ) &&
295+ ' cache_eng_python' %in% ls(asNamespace(' reticulate' ))) {
296+ getFromNamespace(' cache_eng_python' , ' reticulate' )
297+ } else {
298+ NULL
299+ }
300+ }
301+
291302# # Java
292303# e.g. see http://cran.rstudio.com/package=jvmr
293304
@@ -925,11 +936,7 @@ knit_engines$set(
925936 verbatim = eng_verbatim
926937)
927938
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- }
939+ cache_engines $ set(python = cache_eng_python )
933940
934941get_engine = function (name ) {
935942 fun = knit_engines $ get(name )
0 commit comments