diff options
author | Alastair Tse <liquidx@gentoo.org> | 2005-04-26 13:27:34 +0000 |
---|---|---|
committer | Alastair Tse <liquidx@gentoo.org> | 2005-04-26 13:27:34 +0000 |
commit | ad3ed6b431c60b39d5aab1b48e2e0804f5e521b1 (patch) | |
tree | 37d4030a363ef1d9875680129920ef55da8df7d6 /dev-python | |
parent | Added new upstream version 1.0.1, with new configure patch. Dropped patches a... (diff) | |
download | gentoo-2-ad3ed6b431c60b39d5aab1b48e2e0804f5e521b1.tar.gz gentoo-2-ad3ed6b431c60b39d5aab1b48e2e0804f5e521b1.tar.bz2 gentoo-2-ad3ed6b431c60b39d5aab1b48e2e0804f5e521b1.zip |
revision bump to compile with R-2.0.0 via some ugly hack
(Portage version: 2.0.51.19)
Diffstat (limited to 'dev-python')
-rw-r--r-- | dev-python/rpy/ChangeLog | 14 | ||||
-rw-r--r-- | dev-python/rpy/Manifest | 7 | ||||
-rw-r--r-- | dev-python/rpy/files/digest-rpy-0.3.5-r1 | 2 | ||||
-rw-r--r-- | dev-python/rpy/files/rpy-0.3.5-cvs_backport.patch | 1419 | ||||
-rw-r--r-- | dev-python/rpy/rpy-0.3.5-r1.ebuild | 41 | ||||
-rw-r--r-- | dev-python/rpy/rpy-0.3.5.ebuild | 10 |
6 files changed, 1484 insertions, 9 deletions
diff --git a/dev-python/rpy/ChangeLog b/dev-python/rpy/ChangeLog index 488e7a0b40c6..b597869b553d 100644 --- a/dev-python/rpy/ChangeLog +++ b/dev-python/rpy/ChangeLog @@ -1,10 +1,20 @@ # ChangeLog for dev-python/rpy -# Copyright 2000-2004 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/rpy/ChangeLog,v 1.6 2004/12/31 00:34:54 ciaranm Exp $ +# Copyright 2000-2005 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/rpy/ChangeLog,v 1.7 2005/04/26 13:27:34 liquidx Exp $ + +*rpy-0.3.5-r1 (26 Apr 2005) + + 26 Apr 2005; Alastair Tse <liquidx@gentoo.org> + +files/rpy-0.3.5-cvs_backport.patch, rpy-0.3.5.ebuild, + +rpy-0.3.5-r1.ebuild: + revision bump to compile with R-2.0.0 via some ugly hack 31 Dec 2004; Ciaran McCreesh <ciaranm@gentoo.org> : Change encoding to UTF-8 for GLEP 31 compliance + 19 Oct 2004; Alastair Tse <liquidx@gentoo.org> rpy-0.3.5.ebuild: + pegging dep on dev-lang/R-1.91 because 2.0.0 doesn't work with these bindings + 18 Oct 2004; Alastair Tse <liquidx@gentoo.org> rpy-0.3.5.ebuild: fix problem with undefined reference to MAIN__ if using libf2c diff --git a/dev-python/rpy/Manifest b/dev-python/rpy/Manifest index 0e70e429819e..242686aceb08 100644 --- a/dev-python/rpy/Manifest +++ b/dev-python/rpy/Manifest @@ -1,4 +1,7 @@ -MD5 40594614357ef07e006e937954f32bb1 ChangeLog 788 -MD5 088d2be524d0a4793861f6738f6d0c4e rpy-0.3.5.ebuild 732 +MD5 a308f74ddb38526334812a4c6784830a ChangeLog 936 MD5 71c4638c9c88af75b58e5f5cb54fe008 metadata.xml 159 +MD5 1fe4f4b9e33a53b3a240998910a4d466 rpy-0.3.5.ebuild 737 +MD5 4fabbf36df166a01b3cd31b245965deb rpy-0.3.5-r1.ebuild 1073 MD5 179eb32e38a74c76d927b363d99e7327 files/digest-rpy-0.3.5 60 +MD5 581447dc98908d7d7babd7d3671a18a1 files/digest-rpy-0.3.5-r1 121 +MD5 aad47b270909bcad627500f562dc0613 files/rpy-0.3.5-cvs_backport.patch 42587 diff --git a/dev-python/rpy/files/digest-rpy-0.3.5-r1 b/dev-python/rpy/files/digest-rpy-0.3.5-r1 new file mode 100644 index 000000000000..156577443ef5 --- /dev/null +++ b/dev-python/rpy/files/digest-rpy-0.3.5-r1 @@ -0,0 +1,2 @@ +MD5 afc9ee721007ab1f04d4948f5e4c3787 rpy-0.3.5.tar.gz 72829 +MD5 3900bca37cabb4b76b8d736d51cc9251 R-2.0.0.tar.gz 10676072 diff --git a/dev-python/rpy/files/rpy-0.3.5-cvs_backport.patch b/dev-python/rpy/files/rpy-0.3.5-cvs_backport.patch new file mode 100644 index 000000000000..97af0d7ff8a9 --- /dev/null +++ b/dev-python/rpy/files/rpy-0.3.5-cvs_backport.patch @@ -0,0 +1,1419 @@ +Only in rpy: CVS +Only in rpy-0.3.5: ChangeLog +Only in rpy-0.3.5: ChangeLog.rej +Only in rpy-0.3.5: ChangeLog~ +Only in rpy-0.3.5: PKG-INFO +diff -ur rpy-0.3.5/README rpy/README +--- rpy-0.3.5/README 2004-01-16 06:29:31.000000000 +0000 ++++ rpy/README 2004-09-13 22:22:51.000000000 +0100 +@@ -45,10 +45,10 @@ + not, the following steps should be enough: + + <go to the R source directory> +- make distclean +- ./configure --enable-R-shlib +- make +- make install ++ make distclean ++ ./configure --enable-R-shlib ++ make ++ make install + + (Solaris users, please, see the note (a) below.) + +@@ -57,17 +57,17 @@ + /usr/local/lib/R): + + o make a link to RHOME/bin/libR.so in /usr/local/lib or /usr/lib, then +- run 'ldconfig', ++ run 'ldconfig', + + o or, put the following line in your .bashrc (or equivalent): + +- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:RHOME/bin ++ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:RHOME/bin + + o or, edit the file /etc/ld.so.conf and add the following line: + + RHOME/bin + +- and then, run 'ldconfig'. ++ and then, run 'ldconfig'. + + (c) Now, just type: + +@@ -79,7 +79,7 @@ + directory, just read the README file in that directory. For a quickier test, + launch the Python interpreter and import the module 'rpy': + +- Python 2.2 (#2, Dec 23 2001, 16:30:35) ++ Python 2.2 (#2, Dec 23 2001, 16:30:35) + [GCC 2.95.4 20010703 (Debian prerelease)] on linux2 + Type "help", "copyright", "credits" or "license" for more information. + >>> import rpy +@@ -187,25 +187,25 @@ + My path [with a newline added after each ';' for clarity, + remove these for the actual variable value!] is: + +- C:\Progra~1\Micros~3\Common\MSDev98\Bin; +- C:\Progra~1\Micros~3\VC98\BIN; +- C:\Progra~1\Micros~3\Common\TOOLS; +- C:\Progra~1\Micros~3\Common\TOOLS\WINNT; +- C:\Progra~1\Micros~2\Office; +- C:\WINNT\system32; +- C:\WINNT; +- C:\WINNT\System32\Wbem; +- C:\Progra~1\R\rw1081\bin; +- C:\Progra~1\R\tools; +- C:\Progra~1\R\tools\bin; +- C:\python23; +- +- IMPORTANT: Use the alternative 8 character name for any long +- names or names that contain spaces. +- +- Note that this list includes several Visual C directories, +- the bin directory of the installed version of R, the tools +- directory, the MinGW bin directory, and the python directory. ++ C:\Progra~1\Micros~3\Common\MSDev98\Bin; ++ C:\Progra~1\Micros~3\VC98\BIN; ++ C:\Progra~1\Micros~3\Common\TOOLS; ++ C:\Progra~1\Micros~3\Common\TOOLS\WINNT; ++ C:\Progra~1\Micros~2\Office; ++ C:\WINNT\system32; ++ C:\WINNT; ++ C:\WINNT\System32\Wbem; ++ C:\Progra~1\R\rw1081\bin; ++ C:\Progra~1\R\tools; ++ C:\Progra~1\R\tools\bin; ++ C:\python23; ++ ++ IMPORTANT: Use the alternative 8 character name for any long ++ names or names that contain spaces. ++ ++ Note that this list includes several Visual C directories, ++ the bin directory of the installed version of R, the tools ++ directory, the MinGW bin directory, and the python directory. + + Step 5: Modify the first few lines of the rpywin "setup.py" file to + give the paths where you installed the R binary and source code. +@@ -214,26 +214,55 @@ + + in the rpywin directory do + +- set RSRC=C:\Program Files\R\src\R-1.8.1 +- set RHOME=C:\Program Files\R\rw1018 ++ set RSRC=C:\Progra~1\R\src\R-1.9.1 ++ set RHOME=C:\Progra~1\R\rw1091 + +- lib /def:%RSRC%\src\gnuwin32\R.exp /machine:ix86 ++ lib /def:%RHOME%\src\gnuwin32\R.exp /machine:ix86 + /out:%RHOME%/bin/Rdll.lib + +- [The lib command should be all on one line.] ++ [The lib command should be all on one line.] ++ ++ ALTERNATIVE (added by Matjaz Kukar) ++ You may also using pexports, see distutils documentation or ++ http://starship.python.net/crew/kernr/mingw32/Notes.html): ++ ++ pexports %RHOME%/bin/R.dll > %RHOME%/bin/Rdll.def ++ lib/def:%RHOME%/bin/Rdll.def /out:%RHOME%/bin/Rdll.lib /machine:ix86 ++ ++ Somehow, by this approach more external variables from R.dll ++ may be linked with, if declared as ++ ++ __declspec(dllimport) FILE *R_Outputfile; ++ __declspec(dllimport) int UserBreak; ++ ++ Puzzling fact: UserBreak can be linked with in both cases, ++ whereas R_Outputfile only in the second (pexports) case. ++ + + Step 7: Build rpy: + +- in the rpywin directory do: ++ in the rpywin directory do: + +- python setup.py build ++ python setup.py build + + Step 8: Install rpy: + +- python setup.py install ++ python setup.py install + + All done! + ++NOTE about compiling with Visual C++ 7 for Python 2.3: you may need to patch ++msvccompiler.py from the distutils module. VC7 handling seems to be broken, ++in my case I needed to change line 212 to ++ ++if False: # len (self.__paths) == 0: ++ ++in order to prevent raising the followin error: ++ ++"Python was built with version 6 of Visual Studio, ++and extensions need to be built with the same ++version of the compiler, but it isn't installed." ++ + 3. USING RPy + + For details see the documentation in the 'doc' directory. As a quick example, +Only in rpy/debian: CVS +Only in rpy/doc: CVS +Only in rpy-0.3.5/doc: Makefile.old +diff -ur rpy-0.3.5/doc/manual.texi rpy/doc/manual.texi +--- rpy-0.3.5/doc/manual.texi 2004-02-17 18:57:17.000000000 +0000 ++++ rpy/doc/manual.texi 2004-08-23 22:18:42.000000000 +0100 +@@ -319,7 +319,7 @@ + @node R objects look up, Robj type, Interface description, Interface description + @section R objects look up + +-There are two ways of retrieve a @R{} object via the @Python{} ++There are two ways of retrieving a @R{} object via the @Python{} + @code{r} object: + + @itemize @bullet +@@ -535,7 +535,7 @@ + which is used when the default mode is set to @samp{NO_DEFAULT}, + (@pxref{Python to R}). When no argument is passed to this method, it + displays the current local conversion mode of the object. (The two +-names are synonym for compatibility with version 0.1.) ++names are synonyms for compatibility with version 0.1.) + + @item lcall([argument list]) + This method calls the R object (if callable) using the parameters +Only in rpy-0.3.5/doc: manual.texi.old +Only in rpy/examples: CVS +Only in rpy/examples/useful: CVS +diff -ur rpy-0.3.5/rpy.py rpy/rpy.py +--- rpy-0.3.5/rpy.py 2004-02-04 21:26:46.000000000 +0000 ++++ rpy/rpy.py 2004-02-27 04:45:44.000000000 +0000 +@@ -16,7 +16,7 @@ + # + # High level module for managing the lookup of R objects. + # +-# $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++# $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + # + # + from __future__ import nested_scopes +diff -ur rpy-0.3.5/rpy_io.py rpy/rpy_io.py +--- rpy-0.3.5/rpy_io.py 2004-02-04 21:27:15.000000000 +0000 ++++ rpy/rpy_io.py 2004-02-27 17:05:40.000000000 +0000 +@@ -16,7 +16,7 @@ + # + # Basic io. + # +-# $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++# $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + # + # + +diff -ur rpy-0.3.5/rpy_version.py rpy/rpy_version.py +--- rpy-0.3.5/rpy_version.py 2004-02-18 03:03:55.000000000 +0000 ++++ rpy/rpy_version.py 2004-10-23 02:55:52.000000000 +0100 +@@ -1 +1 @@ +-rpy_version = "0.3.5" ++rpy_version = "0.3.5-CVS" +diff -ur rpy-0.3.5/setup.py rpy/setup.py +--- rpy-0.3.5/setup.py 2004-02-17 18:19:15.000000000 +0000 ++++ rpy/setup.py 2004-09-13 22:27:18.000000000 +0100 +@@ -8,17 +8,22 @@ + def get_R_HOME(): + if sys.platform == 'win32': + import win32api, win32con +- +- hkey = win32api.RegOpenKeyEx( win32con.HKEY_LOCAL_MACHINE, +- "Software\\R-core\\R", +- 0, win32con.KEY_QUERY_VALUE ) +- # get the base directory +- rhome = win32api.RegQueryValueEx( hkey, "InstallPath" )[0] +- win32api.RegCloseKey( hkey ) ++ rhome = os.getenv("R_HOME") ++ if not rhome: ++ try: ++ hkey = win32api.RegOpenKeyEx( win32con.HKEY_LOCAL_MACHINE, ++ "Software\\R-core\\R", ++ 0, win32con.KEY_QUERY_VALUE ) ++ # get the base directory ++ rhome = win32api.RegQueryValueEx( hkey, "InstallPath" )[0] ++ win32api.RegCloseKey( hkey ) ++ except: ++ raise DistutilsExecError("couldn't execute the R interpreter.\n" ++ "Check whether R is in the execution path.") + return rhome + else: + stat, rhome = commands.getstatusoutput('R RHOME') +- if stat: ++ if stat or len(rhome)<=0: + raise DistutilsExecError("couldn't execute the R interpreter.\n" + "Check whether R is in the execution path.") + return rhome +@@ -43,7 +48,7 @@ + get_config_vars()['OPT'] = '-DNDEBUG -g -O3 -Wall' + + # get the Python version +-if sys.version[:3] == '2.2': ++if sys.version[:3] >= '2.2': + DEFINE = [] + UNDEF = ['PRE_2_2'] + else: +@@ -52,28 +57,54 @@ + + # configure the R paths + RHOME = get_R_HOME() +-DEFINE.append(('R_HOME', '"%s"' %RHOME)) ++if sys.platform=="win32": ++ DEFINE.append(('R_HOME', '\\"%s\\"' % RHOME.replace("\\","/") )) ++else: ++ DEFINE.append(('R_HOME', '"%s"' % RHOME)) ++ ++### Caution: don't do -->DEFINE.append(('R_HOME', "'%s'" %RHOME))<--- ++### it doesn't work under Unix. + + r_libs = os.path.join(RHOME, 'bin') + source_files = ["src/rpymodule.c", "src/R_eval.c", + "src/io.c"] ++ + if sys.platform=='win32': + RSRC = get_R_SRC() +- include_dirs = [ os.path.join(RHOME.strip(), 'src/include'), +- os.path.join(RSRC.strip(), 'src/include'), 'src' ] +- libraries=["Rdll","Advapi32"] +- library_dirs = [r_libs, "C:\rpy\bin"] ++ include_dirs = [ os.path.join(RHOME.strip(), 'src\\include'), ++ os.path.join(RSRC.strip(), 'src\\include'), 'src' ] ++ libraries=["Rdll","Advapi32"] ++ library_dirs = [r_libs] ++ #runtime_libs = [r_libs] ++ extra_compile_args= ["-wd4068"] # Disable unknown pragma warning in pyconfig.h ++ source_files = source_files + ["src\\setenv.c"] ++elif sys.platform=='darwin': ++ RSRC = get_R_SRC() ++ include_dirs = [ os.path.join(RHOME.strip(), 'include'), ++ os.path.join(RSRC.strip(), 'src/include'), ++ 'src' ] ++ libraries=['R'] ++ library_dirs=[os.path.join(RHOME.strip(), 'Frameworks')] + extra_compile_args=[] ++ runtime_libs = [] ++elif sys.platform=='osf1V5': ++ RSRC = get_R_SRC() ++ include_dirs = [ os.path.join(RHOME.strip(), 'include'), ++ os.path.join(RSRC.strip(), 'src/include'), ++ 'src' ] ++ libraries=["R"] ++ library_dirs = [r_libs] ++ runtime_libs = [] ++ extra_compile_args=["-shared"] + source_files = source_files + ["src/setenv.c"] +-elif sys.platform=='darwin': +- include_dirs = [ os.path.join(RHOME.strip(), 'include'), 'src' ] +- libraries=['R'] +- library_dirs=[os.path.join(RHOME.strip(), 'Frameworks')] +- extra_compile_args=[] + else: # unix-like systems, this is known to work for Linux and Solaris +- include_dirs = [ os.path.join(RHOME.strip(), 'include'), 'src' ] ++ RSRC = get_R_SRC() ++ include_dirs = [ os.path.join(RHOME.strip(), 'include'), ++ os.path.join(RSRC.strip(), 'src/include'), ++ 'src' ] + libraries=["R"] + library_dirs = [r_libs] ++ runtime_libs = [r_libs] + extra_compile_args=["-shared"] + source_files = source_files + ["src/setenv.c"] + +@@ -93,25 +124,49 @@ + converted to Python exceptions.""" + + +-setup(name="rpy", +- version=rpy_version, +- description="Python interface to the R language", +- author="Walter Moreira", +- author_email="walterm@cmat.edu.uy", +- url="http://rpy.sourceforge.net", +- license="GPL", +- long_description=LONG_DESC, +- py_modules=['rpy', 'rpy_io', 'rpy_version'], +- ext_modules=[Extension("_rpy", +- source_files, +- include_dirs=include_dirs, +- libraries=libraries, +- library_dirs=library_dirs, +- define_macros=DEFINE, +- undef_macros=UNDEF, +- extra_compile_args=extra_compile_args, +- runtime_library_dirs = [r_libs], +- ), + +- ] ++if sys.platform=='win32': ++ setup(name="rpy", ++ version=rpy_version, ++ description="Python interface to the R language", ++ author="Walter Moreira", ++ author_email="walterm@cmat.edu.uy", ++ url="http://rpy.sourceforge.net", ++ license="GPL", ++ long_description=LONG_DESC, ++ py_modules=['rpy', 'rpy_io', 'rpy_version'], ++ ext_modules=[Extension("_rpy", ++ source_files, ++ include_dirs=include_dirs, ++ libraries=libraries, ++ library_dirs=library_dirs, ++ define_macros=DEFINE, ++ undef_macros=UNDEF, ++ extra_compile_args=extra_compile_args ++ ), ++ ++ ] ++ ) ++else: ++ setup(name="rpy", ++ version=rpy_version, ++ description="Python interface to the R language", ++ author="Walter Moreira", ++ author_email="walterm@cmat.edu.uy", ++ url="http://rpy.sourceforge.net", ++ license="GPL", ++ long_description=LONG_DESC, ++ py_modules=['rpy', 'rpy_io', 'rpy_version'], ++ ext_modules=[Extension("_rpy", ++ source_files, ++ include_dirs=include_dirs, ++ libraries=libraries, ++ library_dirs=library_dirs, ++ define_macros=DEFINE, ++ undef_macros=UNDEF, ++ extra_compile_args=extra_compile_args, ++ runtime_library_dirs = runtime_libs, ++ ), ++ ++ ] + ) +Only in rpy/src: CVS +diff -ur rpy-0.3.5/src/RPy.h rpy/src/RPy.h +--- rpy-0.3.5/src/RPy.h 2004-02-12 02:37:40.000000000 +0000 ++++ rpy/src/RPy.h 2004-10-23 02:55:53.000000000 +0100 +@@ -16,20 +16,36 @@ + * + * Public API for calling R. + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + + #ifndef _RPY_H + #define _RPY_H + ++#ifdef _WIN32 ++#undef ERROR /* nameclash with Rext/RS.h */ ++#include <windows.h> ++#undef ERROR ++#endif /*_WIN32*/ ++ + #include <R.h> + #include <Rdefines.h> + #include <Rinternals.h> ++#include <Rversion.h> + #include <Python.h> + #include <R_ext/Rdynload.h> + #include <R_ext/eventloop.h> + ++#ifdef _WIN32 ++#define Win32 /* needed to get definition for UIMode */ ++#include <Startup.h> ++#undef Win32 ++#include <Graphics.h> ++#else ++#include <Startup.h> ++#endif ++ + #include <signal.h> + + #include "robjobject.h" +@@ -69,11 +85,38 @@ + extern void init_io_routines(PyObject *); + + /* I/O functions */ ++#ifdef _WIN32 ++__declspec(dllimport) FILE *R_Outputfile; ++#else + extern FILE *R_Outputfile; ++#endif ++ ++#ifdef _WIN32 ++extern void RPy_WriteConsole(char *, int); ++extern int RPy_ReadConsole(char *, char *, int, int); ++#endif ++ + extern void (*ptr_R_WriteConsole)(char *, int); + extern int (*ptr_R_ReadConsole)(char *, unsigned char *, int, int); + extern int (*ptr_R_ShowFiles)(int, char **, char **, char *, int, char *); + ++#ifdef _WIN32 ++extern void R_WriteConsole(char *, int); ++extern int R_ReadConsole(char *, unsigned char *, int, int); ++extern void R_ProcessEvents(void); ++extern char *getDLLVersion(); ++extern void R_DefParams(Rstart); ++extern void R_SetParams(Rstart); ++extern void setup_term_ui(void); ++extern char *getRHOME(void); ++__declspec(dllimport) int UserBreak; ++#endif ++ ++ ++ ++ ++ ++ + + /* Setters for io functions */ + PyObject *set_output(PyObject *self, PyObject *args); +diff -ur rpy-0.3.5/src/R_eval.c rpy/src/R_eval.c +--- rpy-0.3.5/src/R_eval.c 2004-02-17 18:48:27.000000000 +0000 ++++ rpy/src/R_eval.c 2004-10-22 14:06:13.000000000 +0100 +@@ -1,136 +1,143 @@ +-/* +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation; either version 2 of the License, or +- * (at your option) any later version. +- * +- * This program is distributed in the hope that it will be useful, +- * but WITHOUT ANY WARRANTY; without even the implied warranty of +- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +- * GNU General Public License for more details. +- * +- * You should have received a copy of the GNU General Public License +- * along with this program; if not, write to the Free Software +- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +- * +- * +- * Evaluation of R expressions. +- * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ +- * +- */ +- +-#include <RPy.h> +- +-/* The Python original SIGINT handler */ +-PyOS_sighandler_t python_sigint; +- +-/* Indicates whether the R interpreter was interrupted by a SIGINT */ +-int interrupted = 0; +- +-/* Abort the current R computation due to a SIGINT */ +-void interrupt_R(int signum) +-{ +- interrupted = 1; +- error("Interrupted"); +-} +- +- +-/* Evaluate a SEXP. It must be constructed by hand. It raises a Python +- exception if an error ocurred in the evaluation */ +-SEXP do_eval_expr(SEXP e) { +- SEXP res; +- int error = 0; +- PyOS_sighandler_t old_int; +- +- /* Enable our handler for SIGINT inside the R +- interpreter. Otherwise, we cannot stop R calculations, since +- SIGINT is only processed between Python bytecodes. Also, save the +- Python SIGINT handler because it is necessary to temporally +- restore it in user defined I/O Python functions. */ +- stop_events(); +- +- #ifdef _WIN32 +- old_int = PyOS_getsig(SIGBREAK); +- #else +- old_int = PyOS_getsig(SIGINT); +- #endif +- python_sigint = old_int; +- +- signal(SIGINT, interrupt_R); +- +- interrupted = 0; +- res = R_tryEval(e, R_GlobalEnv, &error); +- +- #ifdef _WIN32 +- PyOS_setsig(SIGBREAK, old_int); +- #else +- PyOS_setsig(SIGINT, old_int); +- #endif +- +- start_events(); +- +- if (error) { +- if (interrupted) { +- PyErr_SetNone(PyExc_KeyboardInterrupt); +- } +- else +- PyErr_SetString(RPyExc_Exception, get_last_error_msg()); +- return NULL; +- } +- +- +- return res; +-} +- +-/* Evaluate a function given by a name (without arguments) */ +-SEXP do_eval_fun(char *name) { +- SEXP exp, fun, res; +- +- fun = get_from_name(name); +- if (!fun) +- return NULL; +- +- PROTECT(fun); +- PROTECT(exp = allocVector(LANGSXP, 1)); +- SETCAR(exp, fun); +- +- PROTECT(res = do_eval_expr(exp)); +- UNPROTECT(3); +- return res; +-} +- +-/* +- * Get an R object from his name. When not found, an exception is +- * raised. The checking of the length of the identifier is needed to +- * avoid that R raises an error. If this happens, Python dumps core. +- */ +-SEXP get_from_name(char *ident) { +- SEXP obj; +- +- /* For R not to throw an error, we must check the identifier is +- neither null nor greater than MAXIDSIZE */ +- if (!*ident) { +- PyErr_SetString(RPyExc_Exception, "attempt to use zero-length variable name"); +- return NULL; +- } +- if (strlen(ident) > MAXIDSIZE) { +- PyErr_SetString(RPyExc_Exception, "symbol print-name too long"); +- return NULL; +- } +- +- obj = Rf_findVar(Rf_install(ident), R_GlobalEnv); +- if (obj == R_UnboundValue) { +- PyErr_Format(RPyExc_Exception, "Object \"%s\" not found", ident); +- return NULL; +- } +- return obj; +-} +- +-/* Obtain the text of the last R error message */ +-char *get_last_error_msg() { +- SEXP msg; +- +- msg = do_eval_fun("geterrmessage"); +- return CHARACTER_VALUE(msg); +-} ++/*
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ *
++ *
++ * Evaluation of R expressions.
++ *
++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $
++ *
++ */
++
++#include <RPy.h>
++
++/* The Python original SIGINT handler */
++PyOS_sighandler_t python_sigint;
++
++/* Indicates whether the R interpreter was interrupted by a SIGINT */
++int interrupted = 0;
++
++/* Abort the current R computation due to a SIGINT */
++void interrupt_R(int signum)
++{
++ interrupted = 1;
++ error("Interrupted");
++}
++
++
++/* Evaluate a SEXP. It must be constructed by hand. It raises a Python
++ exception if an error ocurred in the evaluation */
++SEXP do_eval_expr(SEXP e) {
++ SEXP res;
++ int error = 0;
++ PyOS_sighandler_t old_int;
++
++ /* Enable our handler for SIGINT inside the R
++ interpreter. Otherwise, we cannot stop R calculations, since
++ SIGINT is only processed between Python bytecodes. Also, save the
++ Python SIGINT handler because it is necessary to temporally
++ restore it in user defined I/O Python functions. */
++ stop_events();
++
++ #ifdef _WIN32
++ old_int = PyOS_getsig(SIGBREAK);
++ #else
++ old_int = PyOS_getsig(SIGINT);
++ #endif
++ python_sigint = old_int;
++
++ signal(SIGINT, interrupt_R);
++
++ interrupted = 0;
++ res = R_tryEval(e, R_GlobalEnv, &error);
++
++ #ifdef _WIN32
++ PyOS_setsig(SIGBREAK, old_int);
++ #else
++ PyOS_setsig(SIGINT, old_int);
++ #endif
++
++ start_events();
++
++ if (error) {
++ if (interrupted) {
++ PyErr_SetNone(PyExc_KeyboardInterrupt);
++ }
++ else
++ PyErr_SetString(RPyExc_Exception, get_last_error_msg());
++ return NULL;
++ }
++
++
++ return res;
++}
++
++/* Evaluate a function given by a name (without arguments) */
++SEXP do_eval_fun(char *name) {
++ SEXP exp, fun, res;
++
++ fun = get_from_name(name);
++ if (!fun)
++ return NULL;
++
++ PROTECT(fun);
++ PROTECT(exp = allocVector(LANGSXP, 1));
++ SETCAR(exp, fun);
++
++ PROTECT(res = do_eval_expr(exp));
++ UNPROTECT(3);
++ return res;
++}
++
++/*
++ * Get an R object from his name. When not found, an exception is
++ * raised. The checking of the length of the identifier is needed to
++ * avoid that R raises an error. If this happens, Python dumps core.
++ */
++SEXP get_from_name(char *ident) {
++ SEXP obj;
++
++ /* For R not to throw an error, we must check the identifier is
++ neither null nor greater than MAXIDSIZE */
++ if (!*ident) {
++ PyErr_SetString(RPyExc_Exception, "attempt to use zero-length variable name");
++ return NULL;
++ }
++ if (strlen(ident) > MAXIDSIZE) {
++ PyErr_SetString(RPyExc_Exception, "symbol print-name too long");
++ return NULL;
++ }
++
++#if R_VERSION < 0x20000 // pre-R-2.0.0
++ obj = Rf_findVar(Rf_install(ident), R_GlobalEnv);
++#else
++ obj = Rf_findVar(Rf_install(ident), R_GlobalEnv);
++ if (obj != R_UnboundValue)
++ obj = Rf_findFun(Rf_install(ident), R_GlobalEnv);
++#endif
++
++ if (obj == R_UnboundValue) {
++ PyErr_Format(RPyExc_Exception, "Object \"%s\" not found", ident);
++ return NULL;
++ }
++ return obj;
++}
++
++/* Obtain the text of the last R error message */
++char *get_last_error_msg() {
++ SEXP msg;
++
++ msg = do_eval_fun("geterrmessage");
++ return CHARACTER_VALUE(msg);
++}
+diff -ur rpy-0.3.5/src/io.c rpy/src/io.c +--- rpy-0.3.5/src/io.c 2004-01-08 16:18:56.000000000 +0000 ++++ rpy/src/io.c 2004-02-27 04:47:27.000000000 +0000 +@@ -16,7 +16,7 @@ + * + * Input/Output routines + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + +@@ -78,13 +78,13 @@ + #ifdef _WIN32 + int + RPy_ReadConsole(char *prompt, +- char *buf, +- int len, int addtohistory) ++ char *buf, ++ int len, int addtohistory) + #else + int + RPy_ReadConsole(char *prompt, +- unsigned char *buf, +- int len, int addtohistory) ++ unsigned char *buf, ++ int len, int addtohistory) + #endif + { + PyObject *input_data; +@@ -116,7 +116,7 @@ + + int + RPy_ShowFiles(int nfile, char **file, char **headers, +- char *wtitle, int del, char *pager) ++ char *wtitle, int del, char *pager) + { + PyObject *pyfiles, *pyheaders, *result, *f, *h; + PyOS_sighandler_t old_int; +@@ -146,7 +146,7 @@ + } + + result = PyObject_CallFunction(rpy_showfiles, "OOsi", pyfiles, pyheaders, +- wtitle, del); ++ wtitle, del); + Py_DECREF(pyfiles); + Py_DECREF(pyheaders); + +diff -ur rpy-0.3.5/src/robjobject.h rpy/src/robjobject.h +--- rpy-0.3.5/src/robjobject.h 2004-01-08 16:18:56.000000000 +0000 ++++ rpy/src/robjobject.h 2004-02-27 04:47:27.000000000 +0000 +@@ -16,7 +16,7 @@ + * + * The Robj type + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + +diff -ur rpy-0.3.5/src/rpymodule.c rpy/src/rpymodule.c +--- rpy-0.3.5/src/rpymodule.c 2004-02-17 18:48:27.000000000 +0000 ++++ rpy/src/rpymodule.c 2004-10-23 02:55:53.000000000 +0100 +@@ -16,7 +16,7 @@ + * + * Implementation of the module '_rpy' and the 'Robj' type. + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + +@@ -25,14 +25,9 @@ + + #define NONAMELESSUNION + #include <stdio.h> ++#include <stdlib.h> + #include <string.h> + +-#ifdef _WIN32 +-#include <windows.h> +-#include <Startup.h> +-#endif +- +- + /* Global objects */ + static SEXP get_item; + static SEXP set_item; +@@ -157,10 +152,10 @@ + SEXP robj, rit; + int i, len, state; + int fsm[5][5] = {{0, 0, 0, 0, 0}, +- {0, 1, 2, 3, 0}, +- {0, 2, 2, 3, 0}, +- {0, 3, 3, 3, 0}, +- {0, 0, 0, 0, 4}}; ++ {0, 1, 2, 3, 0}, ++ {0, 2, 2, 3, 0}, ++ {0, 3, 3, 3, 0}, ++ {0, 0, 0, 0, 4}}; + + len = PySequence_Length(obj); + if (len == 0) +@@ -273,7 +268,7 @@ + + pytl = Py_BuildValue("[i]", tl); + obj = (PyArrayObject *)PyArray_ContiguousFromObject((PyObject *)obj, +- PyArray_NOTYPE, 0, 0); ++ PyArray_NOTYPE, 0, 0); + nobj = PyArray_Reshape(obj, pytl); + Py_XDECREF(pytl); + Py_XDECREF(obj); +@@ -354,17 +349,17 @@ + #endif + + } else if ((PySequence_Check(obj)) && +- (PySequence_Size(obj) >= 0)) { +- PROTECT(robj = seq_to_R(obj)); /* No labels */ ++ (PySequence_Size(obj) >= 0)) { ++ PROTECT(robj = seq_to_R(obj)); /* No labels */ + + } else if ((PyMapping_Check(obj)) && +- (PyMapping_Size(obj) >= 0)) { ++ (PyMapping_Size(obj) >= 0)) { + PROTECT(robj = dict_to_R(obj)); + + } else { + PyErr_Format(RPyExc_Exception, "cannot convert from type '%s'", +- obj->ob_type->tp_name); +- PROTECT(robj = NULL); /* Protected to avoid stack inbalance */ ++ obj->ob_type->tp_name); ++ PROTECT(robj = NULL); /* Protected to avoid stack inbalance */ + } + + if (do_decref) { +@@ -402,7 +397,7 @@ + * fastest index */ + static PyObject * + ltranspose(PyObject *list, int *dims, int *strides, +- int pos, int shift, int len) ++ int pos, int shift, int len) + { + PyObject *nl, *it; + int i; +@@ -413,10 +408,10 @@ + if (pos == len-1) { + for (i=0; i<dims[pos]; i++) { + if (!(it = PyList_GetItem(list, i*strides[pos]+shift))) +- return NULL; ++ return NULL; + Py_INCREF(it); + if (PyList_SetItem(nl, i, it) < 0) +- return NULL; ++ return NULL; + } + return nl; + } +@@ -511,12 +506,12 @@ + #endif + + if (!robj) +- return -1; /* error */ ++ return -1; /* error */ + + if (robj == R_NilValue) { + Py_INCREF(Py_None); + *obj = Py_None; +- return 1; /* succeed */ ++ return 1; /* succeed */ + } + + len = GET_LENGTH(robj); +@@ -528,42 +523,42 @@ + case INTSXP: + integers = INTEGER(robj); + if(isFactor(robj)) { +- thislevel = CHAR(STRING_ELT(GET_LEVELS(robj), integers[i]-1)); +- if (!(it = PyString_FromString(thislevel))) +- return -1; ++ thislevel = CHAR(STRING_ELT(GET_LEVELS(robj), integers[i]-1)); ++ if (!(it = PyString_FromString(thislevel))) ++ return -1; + } + else { +- if (!(it = PyInt_FromLong(integers[i]))) +- return -1; ++ if (!(it = PyInt_FromLong(integers[i]))) ++ return -1; + } + break; + case REALSXP: + reals = REAL(robj); + if (!(it = PyFloat_FromDouble(reals[i]))) +- return -1; ++ return -1; + break; + case CPLXSXP: + complexes = COMPLEX(robj); + if (!(it = PyComplex_FromDoubles(complexes[i].r, +- complexes[i].i))) +- return -1; ++ complexes[i].i))) ++ return -1; + break; + case STRSXP: + strings = CHAR(STRING_ELT(robj, i)); + if (!(it = PyString_FromString(strings))) +- return -1; ++ return -1; + break; + case LISTSXP: + if (!(it = to_Pyobj_with_mode(elt(robj, i), 1))) +- return -1; ++ return -1; + break; + case VECSXP: + if (!(it = to_Pyobj_with_mode(VECTOR_ELT(robj, i), 1))) +- return -1; ++ return -1; + break; + default: + Py_DECREF(tmp); +- return 0; /* failed */ ++ return 0; /* failed */ + } + + if (PyList_SetItem(tmp, i, it) < 0) +@@ -574,8 +569,8 @@ + if (dim != R_NilValue) { + #ifdef WITH_NUMERIC + array = to_PyNumericArray(tmp, dim); +- if (array) { /* If the conversion to Numeric succeed.. */ +- *obj = array; /* we are done */ ++ if (array) { /* If the conversion to Numeric succeed.. */ ++ *obj = array; /* we are done */ + Py_DECREF(tmp); + return 1; + } +@@ -631,9 +626,9 @@ + if (!fun) { + PyErr_Clear(); + for (i=0; i<GET_LENGTH(rclass); i++) +- if ((fun = PyDict_GetItemString(class_table, +- CHAR(STRING_ELT(rclass, i))))) +- break; ++ if ((fun = PyDict_GetItemString(class_table, ++ CHAR(STRING_ELT(rclass, i))))) ++ break; + } + else + Py_INCREF(fun); +@@ -689,16 +684,16 @@ + + i = from_proc_table(robj, &fun); + if (i < 0) +- return -1; /* an error occurred */ ++ return -1; /* an error occurred */ + + if (!fun) +- return 0; /* conversion failed */ ++ return 0; /* conversion failed */ + + tmp = (PyObject *)Robj_new(robj, TOP_MODE); + *obj = PyObject_CallFunction(fun, "O", tmp); + Py_DECREF(fun); + Py_DECREF(tmp); +- return 1; /* conversion succeed */ ++ return 1; /* conversion succeed */ + } + + /* Convert a Robj to a Python object via the class table (mode 2) */ +@@ -711,13 +706,13 @@ + fun = from_class_table(robj); + + if (!fun) +- return 0; /* conversion failed */ ++ return 0; /* conversion failed */ + + tmp = (PyObject *)Robj_new(robj, TOP_MODE); + *obj = PyObject_CallFunction(fun, "O", tmp); + Py_DECREF(fun); + Py_DECREF(tmp); +- return 1; /* conversion succeed */ ++ return 1; /* conversion succeed */ + } + + PyObject * +@@ -890,38 +885,38 @@ + if(!it) goto fail_arg; + if( PySequence_Size(it) != 2 ) + { +- Py_DECREF(it); +- goto fail_arg; ++ Py_DECREF(it); ++ goto fail_arg; + } + nobj = PySequence_GetItem(it, 0); + + /* Name can be a string, None, or NULL, error otherwise. */ + if (PyString_Check(nobj)) + { +- name = dotter(PyString_AsString(nobj)); +- Py_DECREF(nobj); ++ name = dotter(PyString_AsString(nobj)); ++ Py_DECREF(nobj); + } + else if (nobj == Py_None) + { +- name = NULL; +- Py_DECREF(nobj); ++ name = NULL; ++ Py_DECREF(nobj); + } + else if(nobj == NULL) + { +- name = NULL; ++ name = NULL; + } + else + { +- Py_DECREF(nobj); +- goto fail_arg; ++ Py_DECREF(nobj); ++ goto fail_arg; + } + + /* Value can be anything. */ + value = PySequence_GetItem(it, 1); + if (!value) + { +- PyMem_Free(name); +- goto fail; ++ PyMem_Free(name); ++ goto fail; + } + + rvalue = to_Robj(value); +@@ -935,8 +930,8 @@ + /* Add name (if present) */ + if (name && strlen(name)>0) + { +- SET_TAG(*e, Rf_install(name)); +- PyMem_Free(name); ++ SET_TAG(*e, Rf_install(name)); ++ PyMem_Free(name); + } + + /* Move index to new end of call */ +@@ -946,7 +941,7 @@ + + fail_arg: + PyErr_SetString(PyExc_ValueError, +- "Argument must be a sequence of (\"name\", value) pairs.\n"); ++ "Argument must be a sequence of (\"name\", value) pairs.\n"); + fail: + return 0; + } +@@ -976,7 +971,7 @@ + if(largs != 1 || !PySequence_Check(args) ) + { + PyErr_SetString(PyExc_ValueError, +- "Argument must be a sequence of (\"name\", value) pairs.\n"); ++ "Argument must be a sequence of (\"name\", value) pairs.\n"); + return NULL; + } + +@@ -1033,7 +1028,7 @@ + static char *kwlist[] = {"val", 0}; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:autoconvert", kwlist, +- &conversion)) ++ &conversion)) + return NULL; + + if (conversion > 3) { +@@ -1060,7 +1055,7 @@ + int conv=default_mode; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:as_py", kwlist, +- &conv)) ++ &conv)) + return NULL; + + if (conv <= -2 || conv > TOP_MODE) { +@@ -1080,7 +1075,7 @@ + {"local_mode", (PyCFunction)Robj_autoconvert, METH_VARARGS|METH_KEYWORDS}, + {"as_py", (PyCFunction)Robj_as_py, METH_VARARGS|METH_KEYWORDS}, + {"lcall", (PyCFunction)Robj_lcall, METH_VARARGS}, +- {NULL, NULL} /* sentinel */ ++ {NULL, NULL} /* sentinel */ + }; + + /* Sequence protocol implementation */ +@@ -1168,14 +1163,14 @@ + + /* We should implement sq_slice, sq_contains ... */ + static PySequenceMethods Robj_as_sequence = { +- (inquiry)Robj_len, /* sq_length */ +- 0, /* sq_concat */ +- 0, /* sq_repeat */ +- (intargfunc)Robj_item, /* sq_item */ +- 0, /* sq_slice */ +- (intobjargproc)Robj_ass_item, /* sq_ass_item */ +- 0, /* sq_ass_slice */ +- 0, /* sq_contains */ ++ (inquiry)Robj_len, /* sq_length */ ++ 0, /* sq_concat */ ++ 0, /* sq_repeat */ ++ (intargfunc)Robj_item, /* sq_item */ ++ 0, /* sq_slice */ ++ (intobjargproc)Robj_ass_item, /* sq_ass_item */ ++ 0, /* sq_ass_slice */ ++ 0, /* sq_contains */ + }; + + +@@ -1193,30 +1188,30 @@ + statichere PyTypeObject Robj_Type = { + /* The ob_type field must be initialized in the module init function + * to be portable to Windows without using C++. */ +-#if defined(PRE_2_2) ++#if defined(PRE_2_2) || defined(_WIN32) // Matjaz + PyObject_HEAD_INIT(NULL) + #else + PyObject_HEAD_INIT(&PyType_Type) + #endif +- 0, /*ob_size*/ +- "Robj", /*tp_name*/ +- sizeof(RobjObject), /*tp_basicsize*/ +- 0, /*tp_itemsize*/ ++ 0, /*ob_size*/ ++ "Robj", /*tp_name*/ ++ sizeof(RobjObject), /*tp_basicsize*/ ++ 0, /*tp_itemsize*/ + /* methods */ + (destructor)Robj_dealloc, /*tp_dealloc*/ +- 0, /*tp_print*/ ++ 0, /*tp_print*/ + #ifdef PRE_2_2 + (getattrfunc)Robj_getattr, + #else + 0, + #endif + 0, +- 0, /*tp_compare*/ +- 0, /*tp_repr*/ +- 0, /*tp_as_number*/ +- &Robj_as_sequence, /*tp_as_sequence*/ +- 0, /*tp_as_mapping*/ +- 0, /*tp_hash*/ ++ 0, /*tp_compare*/ ++ 0, /*tp_repr*/ ++ 0, /*tp_as_number*/ ++ &Robj_as_sequence, /*tp_as_sequence*/ ++ 0, /*tp_as_mapping*/ ++ 0, /*tp_hash*/ + (ternaryfunc)Robj_call, /*tp_call*/ + 0, /*tp_str*/ + #if defined(PRE_2_2) || defined(_WIN32) +@@ -1273,7 +1268,7 @@ + + static char *kwlist[] = {"name", "autoconvert", 0}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|i:get", kwlist, +- &obj_str, &conversion)) ++ &obj_str, &conversion)) + return NULL; + + robj = get_from_name(obj_str); +@@ -1323,7 +1318,7 @@ + + static char *kwlist[] = {"usec", 0}; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i:r_events", +- kwlist, &usec)) ++ kwlist, &usec)) + return NULL; + + if (R_interact) { +@@ -1369,20 +1364,27 @@ + } + + ++void ++r_cleanup(void) ++{ ++ R_CleanUp(SA_NOSAVE, 1, 0); ++} ++ + + /* List of functions defined in the module */ + static PyMethodDef rpy_methods[] = { +- {"get", (PyCFunction)get, METH_VARARGS | METH_KEYWORDS}, +- {"set_mode", (PyCFunction)set_mode, METH_VARARGS}, +- {"get_mode", (PyCFunction)get_mode, METH_VARARGS}, +- {"set_output", (PyCFunction)set_output, METH_VARARGS}, +- {"set_input", (PyCFunction)set_input, METH_VARARGS}, ++ {"get", (PyCFunction)get, METH_VARARGS | METH_KEYWORDS}, ++ {"set_mode", (PyCFunction)set_mode, METH_VARARGS}, ++ {"get_mode", (PyCFunction)get_mode, METH_VARARGS}, ++ {"set_output", (PyCFunction)set_output, METH_VARARGS}, ++ {"set_input", (PyCFunction)set_input, METH_VARARGS}, + {"set_showfiles", (PyCFunction)set_showfiles, METH_VARARGS}, +- {"get_output", (PyCFunction)get_output, METH_VARARGS}, +- {"get_input", (PyCFunction)get_input, METH_VARARGS}, ++ {"get_output", (PyCFunction)get_output, METH_VARARGS}, ++ {"get_input", (PyCFunction)get_input, METH_VARARGS}, + {"get_showfiles", (PyCFunction)get_showfiles, METH_VARARGS}, +- {"r_events", (PyCFunction)r_events, METH_VARARGS | METH_KEYWORDS}, +- {NULL, NULL} /* sentinel */ ++ {"r_events", (PyCFunction)r_events, METH_VARARGS | METH_KEYWORDS}, ++ {"r_cleanup", (PyCFunction)r_cleanup, METH_NOARGS}, ++ {NULL, NULL} /* sentinel */ + }; + + #ifdef _WIN32 +@@ -1448,15 +1450,15 @@ + } + + if (rc == ERROR_SUCCESS) { +- /* set R_HOME */ ++ /* set R_HOME */ + char *buf = (char *) malloc( (strlen( RHome ) + 8) * sizeof( char )); + strcpy( buf, "R_HOME="); + strcat( buf, RHome ); + putenv( buf ); + } + else { +- /* not found, fall back to getRHOME() */ +- strcpy(RHome, getRHOME()); ++ /* not found, fall back to getRHOME() */ ++ strcpy(RHome, getRHOME()); + } + } + } +@@ -1479,22 +1481,29 @@ + + Rp->home = RUser; + Rp->CharacterMode = LinkDLL; +- Rp->ReadConsole = (blah1) R_ReadConsole; +- Rp->WriteConsole = (blah2) R_WriteConsole; ++ ++ Rp->ReadConsole = (blah1) RPy_ReadConsole; // Matjaz ++ Rp->WriteConsole = (blah2) RPy_WriteConsole; // Matjaz ++ + Rp->CallBack = (blah3) RPyDoNothing; + Rp->message = char_message; + Rp->yesnocancel = char_yesnocancel; + Rp->busy = RPyBusy; +- Rp->R_Quiet = 1; ++ Rp->R_Quiet = TRUE; + + /* run as "interactive", so server won't be killed after an error */ + Rp->R_Slave = Rp->R_Verbose = 0; +- Rp->R_Interactive = 1; +- Rp->RestoreAction = 0; /* no restore */ +- Rp->SaveAction = 2; /* no save */ ++ Rp->R_Interactive = TRUE; ++ Rp->RestoreAction = SA_RESTORE; /* no restore */ ++ Rp->SaveAction = SA_NOSAVE; /* no save */ ++ ++#if R_VERSION < 0x20000 // pre-R-2.0.0 ++ + Rp->CommandLineArgs = NULL; + Rp->NumCommandLineArgs = 0; +- ++#else ++ R_set_command_line_arguments(0, NULL); ++#endif + R_SetParams(Rp); /* so R_ShowMessage is set */ + R_SizeFromEnv(Rp); + +@@ -1511,6 +1520,7 @@ + DL_EXPORT(void) + init_rpy(void) + { ++ static char RHome[] = R_HOME; + PyObject *m, *d; + char *defaultargv[] = {"rpy", "-q", "--vanilla"}; + PyOS_sighandler_t old_int; +@@ -1558,9 +1568,21 @@ + init_embedded_win32(); + #else + // envvar c-def +- setenv("R_HOME", R_HOME, 1); ++ if ( strlen(RHome)>0 ) ++ { ++ setenv("R_HOME", RHome, 1); ++ } ++ else ++ { ++ // TODO: put code here to Run R RHOME to get R_HOME value ++ fprintf(stderr, "Error setting R_HOME at build time.\n"); ++ exit(-1); ++ } ++ ++ ++ + Rf_initEmbeddedR( sizeof(defaultargv) / sizeof(defaultargv[0]), +- defaultargv); ++ defaultargv); + #endif + + /* Restore Python handlers */ +@@ -1610,3 +1632,29 @@ + // PyObject_Print(r_lock, stderr, Py_PRINT_RAW); + r_lock = NULL; + } ++ ++ ++#ifndef _WIN32 ++char *getRHOME(void) ++{ ++ char *cmd = "R RHOME"; ++ char *buf; ++ FILE *ptr; ++ int index; ++ ++ buf = malloc(BUFSIZ); ++ ++ if ((ptr = popen(cmd, "r")) != NULL) ++ fgets(buf, BUFSIZ, ptr); ++ (void) pclose(ptr); ++ ++ index = strlen(buf); ++ index--; ++ ++ // strip off trailing newline or CR ++ while( buf[index]=='\n' || buf[index]=='\r' ) ++ buf[index--] = 0; ++ ++ return buf; ++} ++#endif +diff -ur rpy-0.3.5/src/setenv.c rpy/src/setenv.c +--- rpy-0.3.5/src/setenv.c 2004-01-15 22:55:16.000000000 +0000 ++++ rpy/src/setenv.c 2004-02-27 04:47:28.000000000 +0000 +@@ -16,7 +16,7 @@ + * + * For POSIX compliance. + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + +diff -ur rpy-0.3.5/src/setenv.h rpy/src/setenv.h +--- rpy-0.3.5/src/setenv.h 2004-01-08 16:18:56.000000000 +0000 ++++ rpy/src/setenv.h 2004-02-27 04:47:28.000000000 +0000 +@@ -16,7 +16,7 @@ + * + * For POSIX compliance + * +- * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ ++ * $Id: rpy-0.3.5-cvs_backport.patch,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + * + */ + +Only in rpy/tests: CVS +Only in rpy-0.3.5/tests: rpy_test.py diff --git a/dev-python/rpy/rpy-0.3.5-r1.ebuild b/dev-python/rpy/rpy-0.3.5-r1.ebuild new file mode 100644 index 000000000000..a2b28558cb2e --- /dev/null +++ b/dev-python/rpy/rpy-0.3.5-r1.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2005 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-python/rpy/rpy-0.3.5-r1.ebuild,v 1.1 2005/04/26 13:27:34 liquidx Exp $ + +inherit distutils + +DESCRIPTION="RPy is a very simple, yet robust, Python interface to the R Programming Language." +HOMEPAGE="http://rpy.sourceforge.net" +SRC_URI="mirror://sourceforge/rpy/${P}.tar.gz http://cran.r-project.org/src/base/R-2/R-2.0.0.tar.gz" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~x86" +IUSE="" +DEPEND="virtual/python + >=dev-lang/R-2 + dev-python/numeric" + +src_unpack() { + unpack ${A} + cd ${S} + epatch ${FILESDIR}/rpy-0.3.5-cvs_backport.patch + + # compat fix for R-2.0.0 + sed -e "s#^r_libs = .*#r_libs = '/usr/lib/R/lib'#" \ + -i ${S}/setup.py + + # fix for undefined symbol: MAIN__ + echo "int MAIN__( ) { return(0); }" >> ${S}/src/rpymodule.c +} + +src_compile() { + export R_SRC=${WORKDIR}/R-2.0.0 + export R_HOME=/usr/lib/R + distutils_src_compile +} + +src_install() { + export R_SRC=${WORKDIR}/R-2.0.0 + export R_HOME=/usr/lib/R + distutils_src_install +}
\ No newline at end of file diff --git a/dev-python/rpy/rpy-0.3.5.ebuild b/dev-python/rpy/rpy-0.3.5.ebuild index 4c9e95481a7a..9f677cc0ac86 100644 --- a/dev-python/rpy/rpy-0.3.5.ebuild +++ b/dev-python/rpy/rpy-0.3.5.ebuild @@ -1,6 +1,6 @@ -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/rpy/rpy-0.3.5.ebuild,v 1.6 2004/11/01 20:08:52 kloeri Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/rpy/rpy-0.3.5.ebuild,v 1.7 2005/04/26 13:27:34 liquidx Exp $ inherit distutils @@ -12,14 +12,14 @@ SLOT="0" KEYWORDS="~x86" IUSE="" DEPEND="virtual/python - dev-lang/R + <dev-lang/R-2 dev-python/numeric" src_unpack() { unpack ${A} cd ${S} - sed -e "s#^r_libs = .*#r_libs = '/usr/lib/R/lib'#" \ - -i ${S}/setup.py + #sed -e "s#^r_libs = .*#r_libs = '/usr/lib/R/lib'#" \ + # -i ${S}/setup.py # fix for undefined symbol: MAIN__ echo "int MAIN__( ) { return(0); }" >> ${S}/src/rpymodule.c |