Revision: 692
          http://rpy.svn.sourceforge.net/rpy/?rev=692&view=rev
Author:   lgautier
Date:     2008-11-12 19:53:08 +0000 (Wed, 12 Nov 2008)

Log Message:
-----------
merge changes from 2.0.x branch

Modified Paths:
--------------
    rpy2/trunk/NEWS
    rpy2/trunk/doc/source/overview.rst
    rpy2/trunk/doc/source/robjects.rst
    rpy2/trunk/rpy/rinterface/__init__.py
    rpy2/trunk/rpy/robjects/__init__.py
    rpy2/trunk/rpy/robjects/tests/testRObject.py
    rpy2/trunk/rpy/robjects/tests/testRobjects.py

Modified: rpy2/trunk/NEWS
===================================================================
--- rpy2/trunk/NEWS     2008-11-12 19:31:55 UTC (rev 691)
+++ rpy2/trunk/NEWS     2008-11-12 19:53:08 UTC (rev 692)
@@ -4,14 +4,24 @@
 Bugs fixed
 ----------
 
-- Informative message returned as RuntimeError when `R RHOME` does not return
-  anything
+Changes
+-------
 
+- :meth:`RObject.__repr__` moved to :meth:`RObject.r_repr`
 
+
+Bugs fixed
+----------
+
+- Informative message returned as RuntimeError when failing to find R's HOME
+
+- Use the registry to find the R's HOME on win32
+  # snatched from Peter's earlier contribution to rpy-1.x
+
+
 Release 2.0.0rc1
 ================
 
-
 New features
 ------------
 

Modified: rpy2/trunk/doc/source/overview.rst
===================================================================
--- rpy2/trunk/doc/source/overview.rst  2008-11-12 19:31:55 UTC (rev 691)
+++ rpy2/trunk/doc/source/overview.rst  2008-11-12 19:53:08 UTC (rev 692)
@@ -46,7 +46,7 @@
 
   * Python-2.6.0 (numpy-support not tested)
 
-Gcc-4.2.3, then gcc-4.2.4 were used for compiling the C parts.
+`gcc-4.2.3`, then `gcc-4.2.4` were used for compiling the C parts.
 
 
 Download
@@ -67,19 +67,14 @@
 `rpy2` has been reported compiling successfully on all 3 platforms, provided
 that development items such as Python headers and a C compiler are installed.
 
-At the time of writing, Microsoft Windows binaries are contributed by Laurent 
Oget.
 
 Check on the `Sourceforge download page 
<http://downloads.sourceforge.net/rpy>`_
-what is available..
+what is available.
 
+
 .. note::
    Choose files from the `rpy2` package, not `rpy`.
 
-.. note::
-   I have limited time, and at the time of writing no easy access to either
-   Microsoft's windows or Apple's MacOS X. There will no be compiled binaries
-   for the coming month at very least (unless I receive donations of either
-   compiled packages or computers equiped with the mentionned OSes).
 
 .. index::
   single: install;win32
@@ -91,6 +86,9 @@
 If available, the executable can be run; this will install the package
 in the default Python installation.
 
+At the time of writing, Microsoft Windows binaries are contributed 
+by Laurent Oget (from Predictix) since version 2.0.0b1.
+
 .. index::
   single: install;source
 

Modified: rpy2/trunk/doc/source/robjects.rst
===================================================================
--- rpy2/trunk/doc/source/robjects.rst  2008-11-12 19:31:55 UTC (rev 691)
+++ rpy2/trunk/doc/source/robjects.rst  2008-11-12 19:53:08 UTC (rev 692)
@@ -119,10 +119,10 @@
 
 The astute reader will quickly realize that R objects named
 by python variables can
-be plugged into code through their string representation:
+be plugged into code through their `R` representation:
 
 >>> x = robjects.r.rnorm(100)
->>> robjects.r('hist(%s, xlab="x", main="hist(x)")' %repr(x))
+>>> robjects.r('hist(%s, xlab="x", main="hist(x)")' %x.r_repr())
 
 .. warning::
 
@@ -510,7 +510,7 @@
 
 .. code-block:: python
 
-  fit = robjects.r('lm(%s)' %repr(fmla))
+  fit = robjects.r('lm(%s)' %fmla.r_repr())
 
 
 Mapping rpy2 objects to arbitrary python objects

Modified: rpy2/trunk/rpy/rinterface/__init__.py
===================================================================
--- rpy2/trunk/rpy/rinterface/__init__.py       2008-11-12 19:31:55 UTC (rev 
691)
+++ rpy2/trunk/rpy/rinterface/__init__.py       2008-11-12 19:53:08 UTC (rev 
692)
@@ -4,18 +4,36 @@
     R_HOME = os.environ["R_HOME"]
 except KeyError:
     R_HOME = os.popen("R RHOME").readlines()
-    if len(R_HOME) == 0:
+
+if len(R_HOME) == 0:
+    if sys.platform == 'win32':
+        try:
+            import win32api
+            import win32con
+            hkey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
+                                         "Software\\R-core\\R",
+                                         0, win32con.KEY_QUERY_VALUE )
+            R_HOME = win32api.RegQueryValueEx(hkey, "InstallPath")[0]
+            win32api.RegCloseKey( hkey )
+        except:
+            raise RuntimeError(
+                "Unable to determine R version from the registery." +\
+                "Calling the command 'R RHOME' does not return anything.\n" +\
+                    "This might be because R.exe is nowhere in your Path.")
+    else:
         raise RuntimeError(
-            "Calling the command 'R RHOME' does not return anything.\n" +\
-                "This might be because R.exe is nowhere in your Path.")
-    #Twist if 'R RHOME' spits out a warning
+            "R_HOME define, and no R command in the PATH."
+            )
+else:
+#Twist if 'R RHOME' spits out a warning
     if R_HOME[0].startswith("WARNING"):
         R_HOME = R_HOME[1]
     else:
         R_HOME = R_HOME[0]
-    R_HOME = R_HOME.strip()
-    os.environ['R_HOME'] = R_HOME
+        R_HOME = R_HOME.strip()
 
+os.environ['R_HOME'] = R_HOME
+
 # Win32-specific code copied from RPy-1.x
 if sys.platform == 'win32':
     import win32api
@@ -35,8 +53,17 @@
 
     win32api.LoadLibrary( Rlib )
 
+
+# cleanup the namespace
 del(sys)
+del(os)
+try:
+    del(win32api)
+    del(win32con)
+except:
+    pass
 
+
 from rpy2.rinterface.rinterface import *
 
 class StrSexpVector(SexpVector):

Modified: rpy2/trunk/rpy/robjects/__init__.py
===================================================================
--- rpy2/trunk/rpy/robjects/__init__.py 2008-11-12 19:31:55 UTC (rev 691)
+++ rpy2/trunk/rpy/robjects/__init__.py 2008-11-12 19:53:08 UTC (rev 692)
@@ -134,7 +134,11 @@
         s = str.join(os.linesep, s)
         return s
 
-    def __repr__(self):
+    def r_repr(self):
+        """ R string representation for an object.
+        This string representation can be used directed
+        in R code.
+        """
         return repr_robject(self, linesep='\n')
 
     def rclass(self):

Modified: rpy2/trunk/rpy/robjects/tests/testRObject.py
===================================================================
--- rpy2/trunk/rpy/robjects/tests/testRObject.py        2008-11-12 19:31:55 UTC 
(rev 691)
+++ rpy2/trunk/rpy/robjects/tests/testRObject.py        2008-11-12 19:53:08 UTC 
(rev 692)
@@ -18,9 +18,9 @@
         del(ri_v)
         self.assertEquals(rinterface.INTSXP, ro_v.typeof)
 
-    def testRepr(self):
+    def testR_repr(self):
         obj = robjects.baseNameSpaceEnv["pi"]
-        s = obj.__repr__()
+        s = obj.r_repr()
         self.assertTrue(s.startswith('3.14'))
 
 

Modified: rpy2/trunk/rpy/robjects/tests/testRobjects.py
===================================================================
--- rpy2/trunk/rpy/robjects/tests/testRobjects.py       2008-11-12 19:31:55 UTC 
(rev 691)
+++ rpy2/trunk/rpy/robjects/tests/testRobjects.py       2008-11-12 19:53:08 UTC 
(rev 692)
@@ -30,7 +30,7 @@
     def testEval(self):
         # vector long enough to span across more than one line
         x = robjects.baseNameSpaceEnv['seq'](1, 50, 2)
-        res = robjects.r('sum(%s)' %repr(x))
+        res = robjects.r('sum(%s)' %x.r_repr())
         self.assertEquals(625, res[0])
         
 class MappingTestCase(unittest.TestCase):


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to