Revision: 690 http://rpy.svn.sourceforge.net/rpy/?rev=690&view=rev Author: lgautier Date: 2008-11-12 19:04:03 +0000 (Wed, 12 Nov 2008)
Log Message: ----------- - Added automated detection of R's HOME from the registry ( # pointed out by Peter) - edited doc about win32 builds Modified Paths: -------------- rpy2/branches/version_2.0.x/NEWS rpy2/branches/version_2.0.x/doc/source/overview.rst rpy2/branches/version_2.0.x/rpy/rinterface/__init__.py Modified: rpy2/branches/version_2.0.x/NEWS =================================================================== --- rpy2/branches/version_2.0.x/NEWS 2008-11-08 18:07:08 UTC (rev 689) +++ rpy2/branches/version_2.0.x/NEWS 2008-11-12 19:04:03 UTC (rev 690) @@ -4,10 +4,12 @@ Bugs fixed ---------- -- Informative message returned as RuntimeError when `R RHOME` does not return - anything +- 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 ================ Modified: rpy2/branches/version_2.0.x/doc/source/overview.rst =================================================================== --- rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-11-08 18:07:08 UTC (rev 689) +++ rpy2/branches/version_2.0.x/doc/source/overview.rst 2008-11-12 19:04:03 UTC (rev 690) @@ -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 (from Predictix). 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/branches/version_2.0.x/rpy/rinterface/__init__.py =================================================================== --- rpy2/branches/version_2.0.x/rpy/rinterface/__init__.py 2008-11-08 18:07:08 UTC (rev 689) +++ rpy2/branches/version_2.0.x/rpy/rinterface/__init__.py 2008-11-12 19:04:03 UTC (rev 690) @@ -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): 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