R/GetPython.R

Defines functions GetWxPython3 .PullWxUsingPip .GetPython GetPython3 .IsWxAvailable TestWX TestPython GetWxPython27 GetPython27

Documented in GetPython27 GetPython3 GetWxPython27 GetWxPython3 TestPython TestWX

GetPython27 = function(...){
.DeprecatedFunction() 
}

GetWxPython27 =  function(...){
.DeprecatedFunction()
}

TestPython = function(){
HasPython=nzchar(Sys.which("python"))
if(HasPython){
.PythonVersion()
}
else{
.NoSeePython()
}
return(invisible(HasPython))
}


TestWX = function(){
if(TestPython()){
      if (interactive()) {
        if (.Platform$OS.type == "windows") {
shell(paste("python", system.file("Python/TestWX.py", package="BrailleR")))
        } else {
          .WindowsOnly()
        }
}
        if(.IsWxAvailable()){
 .CanSeeWxPython() 
.CanUseWriteR()
return(invisible(TRUE))}
else{ .CannotSeeWxPython() 
return(invisible(FALSE))}
}
}


.IsWxAvailable =
    function(){
TestWx = system('python -c "import wx"')
return(TestWx == 0)
}




GetPython3 =
    function(x64=TRUE) {
      .GetPython(3, x64=x64)
      return(invisible(NULL))
    }

.GetPython =
    function(version, x64=x64) {
      if (interactive()) {
        if (.Platform$OS.type == "windows") {
          if (requireNamespace("BrailleR")) {
            if (requireNamespace("installr")) {
              .DownloadAFile()
bit = .ifelse(x64, 64, 32)

            installr::install.python(version_number = version, download_dir=getOption("BrailleR.Folder"), keep_install_file = TRUE, x64=x64)
             .Added2MyBrailleR()
             .DeleteAnytime()
             }
          }
        } else {
          .WindowsOnly()
        }
      } else {
        .InteractiveOnly()
      }
      return(invisible(NULL))
    }

.PullWxUsingPip = function(){
    if(.IsWxAvailable()){
        system("pip install --user -U wxPython")
        }
    else{
        system("pip install --user wxPython")
        }
        return(invisible(TRUE))
    }



GetWxPython3 =
    function() {
      Success = FALSE
      if (interactive()) {
        if (.Platform$OS.type == "windows") {
          if(TestPython()){
.PullWxUsingPip()
          }
        } else {
          .WindowsOnly()
        }
      } else {
        .InteractiveOnly()
      }
      return(invisible(Success))
    }

Try the BrailleR package in your browser

Any scripts or data that you put into this service are public.

BrailleR documentation built on July 26, 2023, 5:46 p.m.