Re: [Rpy] How do I debug a crash in the windows build of rpy2?

2013-01-22 Thread Christoph Gohlke
On 1/1/2013 3:18 PM, Johan Johansson wrote:
 On Wed, Jan 2, 2013 at 12:07 AM, Laurent Gautier lgaut...@gmail.com wrote:
 On 2013-01-01 23:45, Johan Johansson wrote:

 #if SIZEOF_SIZE_T != SIZEOF_INT
 /* On a 64-bit system, rename the Py_InitModule4 so that 2.4
  modules cannot get loaded into a 2.5 interpreter */
 #define Py_InitModule4 Py_InitModule4_64
 #endif

 The comment suggests that this concerns pre-Python2.4 vs post-Python2.5
 compiled module.
 May be not a big issue for now.

 What worries me is that SIZEOF_SIZE_T shouldn't equal SIZEOF_INT on a
 64-bit system but apparently does. This makes me suspect I'm missing
 compiler flags/defines somewhere.

 Johan


Hi Johan,

did you resolve this? If not, make sure `-m64` and `-DMS_WIN64` are in 
the gcc compiler options. I just tried: rpy2-2.3.x (from hg) builds 
without errors using Rtools216.

Unfortunately the 64 bit extension often (not always, with no apparent 
pattern) fails to load when repeatedly running `python -cimport 
rpy2.rinterface`:

Traceback (most recent call last):
   File string, line 1, in module
   File X:\Python27-x64\lib\site-packages\rpy2\rinterface\__init__.py, 
line 93, in module
 from rpy2.rinterface._rinterface import *
ImportError: DLL load failed: A dynamic link library (DLL) 
initialization routine failed.

The installers are at http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2 
if anyone wants to try.

Christoph

--
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


Re: [Rpy] How do I debug a crash in the windows build of rpy2?

2013-01-02 Thread Johan Johansson
Success:

@@ -188,6 +188,8 @@
 r_exec = os.path.join(r_home, 'bin', 'R')
 # Twist if Win32
 if sys.platform == win32:
+if sys.version.find(64 bit)  0:
+r_exec = os.path.join(r_home, 'bin', 'x64', 'R')
 if sys.version_info = (3,):
 import subprocess
 p = subprocess.Popen(''+r_exec+' --version',
@@ -332,14 +334,19 @@


 def get_rconfig(r_home, about, allow_empty = False):
-r_exec = os.path.join(r_home, 'bin', 'R')
+if sys.platform == win32 and sys.version.find(64 bit)  0:
+r_exec = os.path.join(r_home, 'bin', 'x64', 'R')
+else:
+r_exec = os.path.join(r_home, 'bin', 'R')
 cmd = ''+r_exec+' CMD config '+about
+print cmd
 rp = os.popen(cmd)
 rconfig = rp.readline()
 #Twist if 'R RHOME' spits out a warning
 if rconfig.startswith(WARNING):
 rconfig = rp.readline()
 rconfig = rconfig.strip()
+print rconfig
 rc = RConfig.from_string(rconfig, allow_empty = allow_empty)
 rp.close()
 return rc
@@ -348,6 +355,7 @@
 #r_libs = [os.path.join(RHOME, 'lib'), os.path.join(RHOME, 'modules')]
 r_libs = []
 extra_link_args = []
+extra_compile_args = []

 #FIXME: crude way (will break in many cases)
 #check how to get how to have a configure step
@@ -355,6 +363,12 @@

 if sys.platform == 'win32':
 define_macros.append(('Win32', 1))
+if sys.version.find('64 bit')  0:
+define_macros.append(('Win64', 1))
+extra_link_args.append('-m64')
+extra_compile_args.append('-m64')
+# See http://bugs.python.org/issue4709
+define_macros.append(('MS_WIN64', 1))
 else:
 define_macros.append(('R_INTERFACE_PTRS', 1))
 define_macros.append(('HAVE_POSIX_SIGJMP', 1))
@@ -368,7 +382,6 @@
 else:
 pass

-
 include_dirs = []

 rinterface_ext = Extension(
@@ -403,8 +416,9 @@
 library_dirs = r_libs,
 define_macros = define_macros,
 runtime_library_dirs = r_libs,
+extra_compile_args=extra_compile_args,
 #extra_compile_args=['-O0', '-g'],
-#extra_link_args = extra_link_args
+extra_link_args = extra_link_args
 )

 rpy_device_ext = Extension(
@@ -419,6 +433,7 @@
 library_dirs = r_libs,
 define_macros = define_macros,
 runtime_library_dirs = r_libs,
+extra_compile_args=extra_compile_args,
 #extra_compile_args=['-O0', '-g'],
 extra_link_args = extra_link_args
 )

It turned out to be (mostly) a matter of defining the right
preprocessor symbols. I've run through some of the examples in the
documentation with no obvious ill effects.

Johan

On Wed, Jan 2, 2013 at 12:18 AM, Johan Johansson johan2s...@gmail.com wrote:
 On Wed, Jan 2, 2013 at 12:07 AM, Laurent Gautier lgaut...@gmail.com wrote:
 On 2013-01-01 23:45, Johan Johansson wrote:

 #if SIZEOF_SIZE_T != SIZEOF_INT
 /* On a 64-bit system, rename the Py_InitModule4 so that 2.4
 modules cannot get loaded into a 2.5 interpreter */
 #define Py_InitModule4 Py_InitModule4_64
 #endif

 The comment suggests that this concerns pre-Python2.4 vs post-Python2.5
 compiled module.
 May be not a big issue for now.

 What worries me is that SIZEOF_SIZE_T shouldn't equal SIZEOF_INT on a
 64-bit system but apparently does. This makes me suspect I'm missing
 compiler flags/defines somewhere.

 Johan

--
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


Re: [Rpy] How do I debug a crash in the windows build of rpy2?

2013-01-02 Thread Laurent Gautier
On 2013-01-02 15:25, Johan Johansson wrote:
 Success:

 @@ -188,6 +188,8 @@
   r_exec = os.path.join(r_home, 'bin', 'R')
   # Twist if Win32
   if sys.platform == win32:
 +if sys.version.find(64 bit)  0:
 +r_exec = os.path.join(r_home, 'bin', 'x64', 'R')
   if sys.version_info = (3,):
   import subprocess
   p = subprocess.Popen(''+r_exec+' --version',
 @@ -332,14 +334,19 @@


   def get_rconfig(r_home, about, allow_empty = False):
 -r_exec = os.path.join(r_home, 'bin', 'R')
 +if sys.platform == win32 and sys.version.find(64 bit)  0:
 +r_exec = os.path.join(r_home, 'bin', 'x64', 'R')
 +else:
 +r_exec = os.path.join(r_home, 'bin', 'R')
   cmd = ''+r_exec+' CMD config '+about
 +print cmd
   rp = os.popen(cmd)
   rconfig = rp.readline()
   #Twist if 'R RHOME' spits out a warning
   if rconfig.startswith(WARNING):
   rconfig = rp.readline()
   rconfig = rconfig.strip()
 +print rconfig
   rc = RConfig.from_string(rconfig, allow_empty = allow_empty)
   rp.close()
   return rc
 @@ -348,6 +355,7 @@
   #r_libs = [os.path.join(RHOME, 'lib'), os.path.join(RHOME, 'modules')]
   r_libs = []
   extra_link_args = []
 +extra_compile_args = []

   #FIXME: crude way (will break in many cases)
   #check how to get how to have a configure step
 @@ -355,6 +363,12 @@

   if sys.platform == 'win32':
   define_macros.append(('Win32', 1))
 +if sys.version.find('64 bit')  0:
 +define_macros.append(('Win64', 1))
 +extra_link_args.append('-m64')
 +extra_compile_args.append('-m64')
 +# See http://bugs.python.org/issue4709
 +define_macros.append(('MS_WIN64', 1))
   else:
   define_macros.append(('R_INTERFACE_PTRS', 1))
   define_macros.append(('HAVE_POSIX_SIGJMP', 1))
 @@ -368,7 +382,6 @@
   else:
   pass

 -
   include_dirs = []

   rinterface_ext = Extension(
 @@ -403,8 +416,9 @@
   library_dirs = r_libs,
   define_macros = define_macros,
   runtime_library_dirs = r_libs,
 +extra_compile_args=extra_compile_args,
   #extra_compile_args=['-O0', '-g'],
 -#extra_link_args = extra_link_args
 +extra_link_args = extra_link_args
   )

   rpy_device_ext = Extension(
 @@ -419,6 +433,7 @@
   library_dirs = r_libs,
   define_macros = define_macros,
   runtime_library_dirs = r_libs,
 +extra_compile_args=extra_compile_args,
   #extra_compile_args=['-O0', '-g'],
   extra_link_args = extra_link_args
   )

 It turned out to be (mostly) a matter of defining the right
 preprocessor symbols. I've run through some of the examples in the
 documentation with no obvious ill effects.

Great!

`python -m rpy2.tests` will run all unittests

Win64 users will certainly be happy. Can you submit a pull request ? 
(easier for me). Thanks.

L.



 Johan

 On Wed, Jan 2, 2013 at 12:18 AM, Johan Johansson johan2s...@gmail.com wrote:
 On Wed, Jan 2, 2013 at 12:07 AM, Laurent Gautier lgaut...@gmail.com wrote:
 On 2013-01-01 23:45, Johan Johansson wrote:
 #if SIZEOF_SIZE_T != SIZEOF_INT
 /* On a 64-bit system, rename the Py_InitModule4 so that 2.4
  modules cannot get loaded into a 2.5 interpreter */
 #define Py_InitModule4 Py_InitModule4_64
 #endif
 The comment suggests that this concerns pre-Python2.4 vs post-Python2.5
 compiled module.
 May be not a big issue for now.
 What worries me is that SIZEOF_SIZE_T shouldn't equal SIZEOF_INT on a
 64-bit system but apparently does. This makes me suspect I'm missing
 compiler flags/defines somewhere.

 Johan


--
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


Re: [Rpy] How do I debug a crash in the windows build of rpy2?

2013-01-02 Thread Thomas Kluyver
On 2 January 2013 14:25, Johan Johansson johan2s...@gmail.com wrote:

 +if sys.version.find(64 bit)  0:


General Pythonicness tip, you can check it more readably like this:

if '64 bit' in sys.version:

Best wishes,
Thomas
--
Master Java SE, Java EE, Eclipse, Spring, Hibernate, JavaScript, jQuery
and much more. Keep your Java skills current with LearnJavaNow -
200+ hours of step-by-step video tutorials by Java experts.
SALE $49.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122612 ___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list


Re: [Rpy] How do I debug a crash in the windows build of rpy2?

2013-01-01 Thread Johan Johansson
On Mon, Dec 31, 2012 at 4:25 PM, Laurent Gautier lgaut...@gmail.com wrote:
 Which versions of R, Rtools, and rpy2 did you try this with ? (I am
 understanding from the above that Python is 2.7, and I assume that this is
 the latest in the 2.7 series).

R 2.15.2, Rtools Collection 2.16.0.1923, rpy2 tip and Python 2.7.3. I
get the feeling that the crash is for more fundamental reasons than
version issues though, since it's so early. I've been wrong before
though!

 I have tentatively fixed the C codebase in rpy2 to get
 it to compile with Win64, without having try it (for lack of time - I have
 Python, mingw and R installed in Wine, so technically I only need to sort
 out details). I am pleasantly surprise to hear that it does compile.

Compile it does, but it seems to fail this check in modsupport.h

#if SIZEOF_SIZE_T != SIZEOF_INT
/* On a 64-bit system, rename the Py_InitModule4 so that 2.4
   modules cannot get loaded into a 2.5 interpreter */
#define Py_InitModule4 Py_InitModule4_64
#endif

which forced me to make the same definition on the command line to get
it to link. This makes me suspicious.

 Silly question, but did you already try to compile for Win32 to check that
 the problem is Win64-specific ?

I haven't had time yet, but if my current avenue of exploration
doesn't pan out, I will.

Johan

--
Master SQL Server Development, Administration, T-SQL, SSAS, SSIS, SSRS
and more. Get SQL Server skills now (including 2012) with LearnDevNow -
200+ hours of step-by-step video tutorials by Microsoft MVPs and experts.
SALE $99.99 this month only - learn more at:
http://p.sf.net/sfu/learnmore_122512
___
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list