krlmlr / r-appveyor

Tools for using R with AppVeyor (https://appveyor.com)
132 stars 60 forks source link

Temp directory in .libPaths() #91

Closed bhaskarvk closed 5 years ago

bhaskarvk commented 7 years ago

See https://github.com/krlmlr/r-appveyor/issues/91#issuecomment-314606073 for latest status of this issue.

==== Everything below is obsolete =====

I am using reticulate in one of my packages, and I want to explicitly use python 3.x. So as per https://rstudio.github.io/reticulate/articles/versions.html, I did

environment:
  global:
    PYTHON: "C:\\Python35"
    RETICULATE_PYTHON: "C:\\Python35"

before_test:
  - echo %RETICULATE_PYTHON%

test_script:
  - travis-tool.sh run_tests

The trouble is that RETICULATE_PYTHON never seems to make it to the shell env. which starts R CMD Check from travis-tool.sh run_test. So reticulate uses the first python it finds `C:\Python26" and fails even to load.

  Traceback (most recent call last):
    File "C:/Users/appveyor/AppData/Local/Temp/1/RtmpQ5hFqP/RLIBS_e7c4d863f6/reticulate/config/config.py", line 4, in <module>
      import sysconfig
  ImportError: No module named sysconfig
  Error in python_config(python_version, required_module, python_versions) : 
    Error 1 occurred running C:\Python26\\python.exe 
  Calls: test_check ... eval -> eval -> py_discover_config -> python_config
  In addition: Warning message:
  running command '"C:\Python26\\python.exe" "C:/Users/appveyor/AppData/Local/Temp/1/RtmpQ5hFqP/RLIBS_e7c4d863f6/reticulate/config/config.py"' had status 1 
  testthat results ================================================================
  OK: 0 SKIPPED: 0 FAILED: 0
  Execution halted
* DONE

How do I set custom env. variables before R CMD Check?

bhaskarvk commented 7 years ago

JJ patched the reticulate package to skip python 2.6 if found, but unfortunately even after installing it from github (Remotes: rstudio/reticulate in DESCRIPTION) and explicitly doing travis-tools.sh install_github rstudio/leaflet, there's a temp directory in .libPaths() containing probably the CRAN version of the pkg that shadows the Github version, resulting in the same error.

Is it possible to debug where C:/Users/appveyor/AppData/Local/Temp/1/RtmpucvD1N/RLIBS_e2c1c6a7322/ came from in the .libPaths() ?

Running the tests in 'tests/testthat.R' failed.
Last 13 lines of output:
  [1] "C:/Users/appveyor/AppData/Local/Temp/1/RtmpucvD1N/RLIBS_e2c1c6a7322"
  [2] "C:/R/library"                                                       
  > library(testthat)
  > library(reticulate)
  > py_discover_config("docker")
  Traceback (most recent call last):
    File "C:/Users/appveyor/AppData/Local/Temp/1/RtmpucvD1N/RLIBS_e2c1c6a7322/reticulate/config/config.py", line 8, in <module>
      sys.stdout.write('\nVersionNumber: ' + str(sys.version_info.major) + '.' + str(sys.version_info.minor))
  AttributeError: 'tuple' object has no attribute 'major'
  Error in python_config(python_version, required_module, python_versions) : 
    Error 1 occurred running C:\Python26\\python.exe 
  Calls: py_discover_config -> python_config
  In addition: Warning message:
  running command '"C:\Python26\\python.exe" "C:/Users/appveyor/AppData/Local/Temp/1/RtmpucvD1N/RLIBS_e2c1c6a7322/reticulate/config/config.py"' had status 1 
  Execution halted
* DONE
Status: 1 ERROR
krlmlr commented 7 years ago

Thanks. Can you please test further by adding something like

test_script:
- R -q -e "reticulate::py_discover_config('docker')"

to appveyor.yml?

bhaskarvk commented 7 years ago

Thanks, I will try it out. FWIW there are two issues here

a)The CRAN version of the reticulate package not handling python 2.6 correctly. JJ already fixed that and I've verified that his latest commit fixed the issue.

b) The second problem and this is more on this end is the extra 'tmp' directory in .libPaths(). For now I have managed to bypass it by explicitly adding C:/RLibrary at the front in my testScript.

.libPaths(c("C:/RLibrary",.libPaths()))
.libPaths()
library(reticulate)
py_discover_config("docker")
library(docker)

This seems like a temporary fix, but the real fix would be to not have that temp directory in the .libPaths().

krlmlr commented 6 years ago

I'm not sure where that additional library path comes from, need to investigate if this also happens with a simple package.

krlmlr commented 5 years ago

It seems that the temporary directory is added by R CMD check itself. There's not much we can do here.