Best practice on Windows not clear

Create issue
Issue #2 resolved
Johannes Ranke created an issue

Hi,

thanks for PythonInR. As rPython seems not to be actively maintained, it is a very welcome alternative!

From the documentation, it is not clear to me what I should do if I am a package author and my package uses PythonInR to do some things in python. Should I advise Windows users of the package to always put pyConnect("path/to/python.exe") into their .Rprofile?

Or is it better to check for an existing connection before I use python, call pyConnect() from my package and then use pyExit() when I am done? Obviously this is not necessary on Linux, as I do not need pyConnect().

By the way, is there a reason why pyConnect() does not look for "C:/python27/python.exe" automatically?

Comments (3)

  1. Florian Schwendinger repo owner

    The idea was to keep the connection process on Windows as fexible as possible, it is also possible to use static linkage under Windows. But you are right I should extend the documentation.

    To the other points your right, the current approach has it's drawbacks, would the following work for you?
    I change the package loading that it looks for the environment variable PYTHON_EXE.
    If PYTHON_EXE is found it will use the Python version set in PYTHON_EXE and connect automatically, like on Unix.
    So the user can decide if he sets PYTHON_EXE, puts Sys.setenv into .Rprofile, runs it before loading the package or calls pyConnect after loading the package.

    Sys.setenv(PYTHON_EXE="C:/python27/python.exe")
    library(PythonInR)
    
  2. Log in to comment