PythonNet for Mono, mostly done but need some help

I've good news for Linux, BSD and Mac users. With some outstanding help from the mono mailing list I was able to get PythonNet running on my Ubuntu box. I had a hard time implementing support for UCS-4 unicode representation until Jonathan Pryor and Jonathan Chambers gave me some information and sample code for a custom marshaler. UCS-4 uses up to four bytes to store unicode while Windows is using a wchar (?) or UCS-2 to store unicode. The CLR supports just CharSet.Unicode which is Microsoft's name for UCS-2. Most Linux distributions like Debian/Ubuntu are using a UCS-4 build of Python. After the UCS-4 vs. UCS-2 problem was fixed I was confronted with same nasty seg faults. Brian gave me the tip to search for code that tries to Decref NULL (IntPtr.Zero) and I found three places. One is my fault, one Brian's and the third is equally shared between us since I didn't fix a problem the right way in the first place. Mono seems to be more sensitive to ref counter problems than .NET on Windows. The results are very promising but Mono's generic and overloading support seems to have some flaws. Two unit tests are failing that are working under Windows and a third test is failing early. I'd appreciate any insight knowledge to fix the outstanding tests. ====================================================================== ERROR: testGenericMethodOverloadSelection (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 353, in testGenericMethodOverloadSelection value = type.Overloaded[str]("test") TypeError: No match found for given type params ====================================================================== ERROR: testGenericMethodTypeHandling (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 303, in testGenericMethodTypeHandling self._testGenericMethodByType(System.Boolean, True) File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 202, in _testGenericMethodByType result = stype.Overloaded[ptype](value) TypeError: No match found for given type params ====================================================================== FAIL: Test usage of generic value type definitions. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 81, in testGenericValueType self.failUnless(inst.HasValue) AssertionError I'm also having trouble to create a facade clr module for Mono. The clr.pyd doesn't work under Mono since Unix builds of Python can't load a Windows PE executable. You can find my first and naive approach at http://pythonnet.svn.sourceforge.net/viewvc/pythonnet/branches/clr-2.0-pytho... You can compile it with python setup.py or simple do "$ make -f makefile.mono clr.so". Christian

hi, great job!! i downloaded pythonnet2.5 rev 63, ran make and got python.exe and Python.Runtime.dll. i was not able to get clr.pyd ( or clr.so ), because i have not header files ( jit.h, environment.h....) but i can run mono python.exe and can work with strings: angel@angel-laptop:~/desarrollo/clr-2.0-python-2.5-branch$ mono python.exe Python 2.5.1 (r251:54863, May 2 2007, 16:53:27) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information.
from PythonnetTest import Test a=Test("ÑÑÑÑ ñññ") Constructor. Name= ÑÑÑÑ ñññ print a.Name ÑÑÑÑ ñññ import System import clr dir(clr) ['PythonnetTest', 'System', '__doc__', '__file__', '__name__', 'preload'] clr.preload True
i will test more.. thanks. angel ignacio colmenares laguado 2007/7/17, Christian Heimes <lists@cheimes.de>:
I've good news for Linux, BSD and Mac users. With some outstanding help from the mono mailing list I was able to get PythonNet running on my Ubuntu box.
I had a hard time implementing support for UCS-4 unicode representation until Jonathan Pryor and Jonathan Chambers gave me some information and sample code for a custom marshaler. UCS-4 uses up to four bytes to store unicode while Windows is using a wchar (?) or UCS-2 to store unicode. The CLR supports just CharSet.Unicode which is Microsoft's name for UCS-2. Most Linux distributions like Debian/Ubuntu are using a UCS-4 build of Python.
After the UCS-4 vs. UCS-2 problem was fixed I was confronted with same nasty seg faults. Brian gave me the tip to search for code that tries to Decref NULL (IntPtr.Zero) and I found three places. One is my fault, one Brian's and the third is equally shared between us since I didn't fix a problem the right way in the first place. Mono seems to be more sensitive to ref counter problems than .NET on Windows.
The results are very promising but Mono's generic and overloading support seems to have some flaws. Two unit tests are failing that are working under Windows and a third test is failing early. I'd appreciate any insight knowledge to fix the outstanding tests.
====================================================================== ERROR: testGenericMethodOverloadSelection (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 353, in testGenericMethodOverloadSelection value = type.Overloaded[str]("test") TypeError: No match found for given type params
====================================================================== ERROR: testGenericMethodTypeHandling (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 303, in testGenericMethodTypeHandling self._testGenericMethodByType(System.Boolean, True) File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 202, in _testGenericMethodByType result = stype.Overloaded[ptype](value) TypeError: No match found for given type params
====================================================================== FAIL: Test usage of generic value type definitions. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/heimes/dev/python/pythonnet25/src/tests/test_generic.py", line 81, in testGenericValueType self.failUnless(inst.HasValue) AssertionError
I'm also having trouble to create a facade clr module for Mono. The clr.pyd doesn't work under Mono since Unix builds of Python can't load a Windows PE executable. You can find my first and naive approach at
http://pythonnet.svn.sourceforge.net/viewvc/pythonnet/branches/clr-2.0-pytho... You can compile it with python setup.py or simple do "$ make -f makefile.mono clr.so".
Christian
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
-- Atentamente, angel ignacio colmenares laguado

angel ignacio colmenares laguado wrote:
hi, great job!!
i downloaded pythonnet2.5 rev 63, ran make and got python.exe and Python.Runtime.dll.
i was not able to get clr.pyd ( or clr.so ), because i have not header files ( jit.h, environment.h....) but i can run mono python.exe and can work with strings:
The clr.pyd is useless under Linux. It's a Windows DLL and can't be loaded by Linux's Python. In order to build clr.so you have to install libmono-dev but clr.so is horrible broken. I've run into a nasty problem with Python's small int cache. It's causing seg faults for small ints. Python.Tests.dll can be build under Mono, too. Please run the unit tests for me, would you? :) Christian

ok. i ran unit tests, and this is what i got: angel@angel-laptop:~/desarrollo/clr-2.0-python-2.5-branch$ mono python.exe./src/tests/runtests.py ..............................................................EE....F.......................................................................................................................................................................................................................................................... ====================================================================== ERROR: testGenericMethodOverloadSelection (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py", line 353, in testGenericMethodOverloadSelection value = type.Overloaded[str]("test") TypeError: No match found for given type params ====================================================================== ERROR: testGenericMethodTypeHandling (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py", line 303, in testGenericMethodTypeHandling self._testGenericMethodByType(System.Boolean, True) File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py", line 202, in _testGenericMethodByType result = stype.Overloaded[ptype](value) TypeError: No match found for given type params ====================================================================== FAIL: Test usage of generic value type definitions. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py", line 81, in testGenericValueType self.failUnless(inst.HasValue) AssertionError ---------------------------------------------------------------------- Ran 319 tests in 3.447s FAILED (failures=1, errors=2) 2007/7/18, Christian Heimes <lists@cheimes.de>:
angel ignacio colmenares laguado wrote:
hi, great job!!
i downloaded pythonnet2.5 rev 63, ran make and got python.exe and Python.Runtime.dll.
i was not able to get clr.pyd ( or clr.so ), because i have not header files ( jit.h, environment.h....) but i can run mono python.exe and can work with strings:
The clr.pyd is useless under Linux. It's a Windows DLL and can't be loaded by Linux's Python. In order to build clr.so you have to install libmono-dev but clr.so is horrible broken. I've run into a nasty problem with Python's small int cache. It's causing seg faults for small ints.
Python.Tests.dll can be build under Mono, too. Please run the unit tests for me, would you? :)
Christian
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
-- Atentamente, angel ignacio colmenares laguado

angel ignacio colmenares laguado wrote:
angel@angel-laptop:~/desarrollo/clr-2.0-python-2.5-branch$ mono python.exe./src/tests/runtests.py ..............................................................EE....F..........................................................................................................................................................................................................................................................
====================================================================== ERROR: testGenericMethodOverloadSelection (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py",
line 353, in testGenericMethodOverloadSelection value = type.Overloaded[str]("test") TypeError: No match found for given type params
====================================================================== ERROR: testGenericMethodTypeHandling (test_generic.GenericTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py",
line 303, in testGenericMethodTypeHandling self._testGenericMethodByType(System.Boolean, True) File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py",
line 202, in _testGenericMethodByType result = stype.Overloaded[ptype](value) TypeError: No match found for given type params
====================================================================== FAIL: Test usage of generic value type definitions. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/angel/desarrollo/clr-2.0-python-2.5-branch/src/tests/test_generic.py",
line 81, in testGenericValueType self.failUnless(inst.HasValue) AssertionError
---------------------------------------------------------------------- Ran 319 tests in 3.447s
FAILED (failures=1, errors=2)
Mono's support for overloading seems to have some bugs. On Windows just one unit test related to overloading is failing and it is failing later. I'll have to familiarize myself with MonoDevelop in order to debug the bugs. I've promised Miguel to report them. Christian
participants (2)
-
angel ignacio colmenares laguado
-
Christian Heimes