Revision: 386
          http://rpy.svn.sourceforge.net/rpy/?rev=386&view=rev
Author:   warnes
Date:     2007-11-29 16:56:31 -0800 (Thu, 29 Nov 2007)

Log Message:
-----------
Improve detection of R installation directories on Win32

Modified Paths:
--------------
    trunk/rpy/rpy_wintools.py

Modified: trunk/rpy/rpy_wintools.py
===================================================================
--- trunk/rpy/rpy_wintools.py   2007-11-30 00:55:28 UTC (rev 385)
+++ trunk/rpy/rpy_wintools.py   2007-11-30 00:56:31 UTC (rev 386)
@@ -4,19 +4,43 @@
 import os, os.path, sys, shutil
 import rpy_tools
 
+
 def get_RHOMES():
+
+    # Standard R
+    Rhomes = get_RHOMES_inner("R")
+
+    # RStat, commercially packaged R from Random Technologies LLC
+    Rhomes.extend( get_RHOMES_inner("RStat") )
+   
+    if os.environ.get('RHOME', None):
+        Rhomes.insert(0, os.environ.get('RHOME', None))
+    
+    return Rhomes
+
+def get_RHOMES_inner(progname="R"):
     from win32com.shell import shell, shellcon
     program_files = shell.SHGetFolderPath(0,
                                           shellcon.CSIDL_PROGRAM_FILES,
                                           0,
                                           0)
-    Rdir = os.path.join(program_files,"R")
+
+    Rdir = os.path.join(program_files, progname)
     Rhomes = []
     if os.path.exists(Rdir):
-        Rprogs = os.listdir(Rdir)
-        Rhomes = map( lambda(x): os.path.join(Rdir, x), Rprogs)
-    if os.environ.get('RHOME', None):
-        Rhomes.insert(0, os.environ.get('RHOME', None))
+        RVersionDirs = os.listdir(Rdir)
+        for thisRVersionDir in RVersionDirs:
+          BasePath = os.path.join(Rdir, thisRVersionDir)
+          DLLPath1 = os.path.join(BasePath, "bin", "R.dll" )
+          DLLPath2 = os.path.join(BasePath, "lib", "R.dll" )
+          if os.path.exists(DLLPath1) or os.path.exists(DLLPath2):
+             Rhomes.append(  BasePath )
+    
     return Rhomes
 
-
+if __name__ == '__main__':
+  RHomes = get_RHOMES()
+  print "Found", len(RHomes), " R Installations:"
+  for path in RHomes:
+     print "    ", path
+  print


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to