@@ -2,24 +2,32 @@ acro_venv <- "r-acro"
22acro_package <- " acro==0.4.11"
33python_version <- " >=3.10"
44
5-
65# ' Install acro
76# '
87# ' @param envname the name of the Python virtual environment
8+ # ' @param python the path to Python executable
99# ' @param ... Any other parameters.
1010# '
1111# ' @return No return value, called for side effects
12-
13-
14- install_acro <- function (envname = " r-acro" , ... ) {
12+ install_acro <- function (envname = " r-acro" , python = NULL , ... ) {
13+ # Get Python executable if not provided
14+ if (is.null(python )) {
15+ python <- Sys.which(" python3" )
16+ if (python == " " ) {
17+ python <- Sys.which(" python" )
18+ }
19+ if (python == " " ) {
20+ stop(" Python not found in PATH. Please ensure Python is installed and accessible." )
21+ }
22+ }
23+
1524 # create Python virtual environment
1625 reticulate :: virtualenv_create(
1726 envname = envname ,
18- version = python_version ,
27+ python = python ,
1928 force = TRUE ,
2029 packages = NULL
2130 )
22-
2331 # install Python acro
2432 reticulate :: py_install(acro_package , envname = envname )
2533}
@@ -29,13 +37,17 @@ install_acro <- function(envname = "r-acro", ...) {
2937# ' @param ... Any other parameters.
3038# '
3139# ' @return No return value, called for side effects
32-
3340create_virtualenv <- function (... ) {
41+ # Get Python executable path
42+ python_path <- Sys.which(" python3" )
43+ if (python_path == " " ) {
44+ python_path <- Sys.which(" python" )
45+ }
46+
3447 # ensure a virtual environment exists
3548 if (! reticulate :: virtualenv_exists(acro_venv )) {
36- install_acro(envname = acro_venv )
49+ install_acro(envname = acro_venv , python = python_path )
3750 }
38-
3951 # activate virtual environment
4052 reticulate :: use_virtualenv(acro_venv , required = TRUE )
4153}
0 commit comments