From fuzzyman at voidspace.org.uk Fri Nov 2 17:14:10 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 02 Nov 2007 16:14:10 +0000 Subject: [Python.NET] FromManagedObject and Booleans Message-ID: <472B4CD2.3060506@voidspace.org.uk> Hello all, I'm using the Python.Runtime assembly to provide access to CPython modules from IronPython. I'm converting objects that pass from CPython to IronPython (and vice-versa) by converting datatypes or proxying access. To convert to CPython types I use "PyObject.FromManagedObject(obj)" where possible and do type specific conversion for other types. Unfortunately "PyObject.FromManagedObject(obj)" doesn't work for booleans and passing in booleans to CPython doesn't result in 'True' or 'False', but a 'System.Boolean' instead. As a workaround I'm using: @GIL def _getBools(): "Hack because 'FromManagedObject' doesn't work for bools" builtin = engine.ImportModule('__builtin__') return {False: builtin.GetAttr('False'), True: builtin.GetAttr('True')} _bools = _getBools() Is the fact that "PyObject.FromManagedObject(obj)" doesn't work for booleans a bug? (Or is there an alternative method you can suggest?) All the best, Michael Foord http://www.manning.com/foord From brian.lloyd at revolutionhealth.com Fri Nov 2 17:29:32 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Fri, 02 Nov 2007 12:29:32 -0400 Subject: [Python.NET] FromManagedObject and Booleans In-Reply-To: <472B4CD2.3060506@voidspace.org.uk> Message-ID: That might actually be because bool didn't exist in python way back then ;) I suspect its probably safe to fix it now. -Brian On 11/2/07 12:14 PM, "Michael Foord" wrote: > Hello all, > > I'm using the Python.Runtime assembly to provide access to CPython > modules from IronPython. > > I'm converting objects that pass from CPython to IronPython (and > vice-versa) by converting datatypes or proxying access. > > To convert to CPython types I use "PyObject.FromManagedObject(obj)" > where possible and do type specific conversion for other types. > > Unfortunately "PyObject.FromManagedObject(obj)" doesn't work for > booleans and passing in booleans to CPython doesn't result in 'True' or > 'False', but a 'System.Boolean' instead. > > As a workaround I'm using: > > @GIL > def _getBools(): > "Hack because 'FromManagedObject' doesn't work for bools" > builtin = engine.ImportModule('__builtin__') > return {False: builtin.GetAttr('False'), True: builtin.GetAttr('True')} > > _bools = _getBools() > > Is the fact that "PyObject.FromManagedObject(obj)" doesn't work for > booleans a bug? (Or is there an alternative method you can suggest?) > > All the best, > > > Michael Foord > http://www.manning.com/foord > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com From fuzzyman at voidspace.org.uk Fri Nov 2 17:30:55 2007 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 02 Nov 2007 16:30:55 +0000 Subject: [Python.NET] [python] Re: FromManagedObject and Booleans In-Reply-To: References: Message-ID: <472B50BF.7070402@voidspace.org.uk> Brian Lloyd wrote: > That might actually be because bool didn't exist in python way back > then ;) I suspect its probably safe to fix it now. > Cool. :-) Michael > -Brian > > > On 11/2/07 12:14 PM, "Michael Foord" wrote: > > >> Hello all, >> >> I'm using the Python.Runtime assembly to provide access to CPython >> modules from IronPython. >> >> I'm converting objects that pass from CPython to IronPython (and >> vice-versa) by converting datatypes or proxying access. >> >> To convert to CPython types I use "PyObject.FromManagedObject(obj)" >> where possible and do type specific conversion for other types. >> >> Unfortunately "PyObject.FromManagedObject(obj)" doesn't work for >> booleans and passing in booleans to CPython doesn't result in 'True' or >> 'False', but a 'System.Boolean' instead. >> >> As a workaround I'm using: >> >> @GIL >> def _getBools(): >> "Hack because 'FromManagedObject' doesn't work for bools" >> builtin = engine.ImportModule('__builtin__') >> return {False: builtin.GetAttr('False'), True: builtin.GetAttr('True')} >> >> _bools = _getBools() >> >> Is the fact that "PyObject.FromManagedObject(obj)" doesn't work for >> booleans a bug? (Or is there an alternative method you can suggest?) >> >> All the best, >> >> >> Michael Foord >> http://www.manning.com/foord >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet >> > > -------------------------- > Brian Lloyd > > brian.lloyd at revolutionhealth.com > > > From anakinnani at hotmail.com Tue Nov 6 05:48:34 2007 From: anakinnani at hotmail.com (jane janet) Date: Tue, 6 Nov 2007 04:48:34 +0000 Subject: [Python.NET] Can I create extension file by C#? Message-ID: Hello all, I wanna to know that can i create any extension file or DLL file by using C# and if it can I wanna know how to do too. Please help me. Thank you. _________________________________________________________________ Peek-a-boo FREE Tricks & Treats for You! http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071106/feb7b244/attachment.htm From anakinnani at hotmail.com Tue Nov 6 09:29:48 2007 From: anakinnani at hotmail.com (jane janet) Date: Tue, 6 Nov 2007 08:29:48 +0000 Subject: [Python.NET] What can I do with DLL? Message-ID: Hello all, I'm a student. I wanna know how to do about my project. I implemented aplication using Ironpython because I have to use .NET library and c# code but I also have to use this application with another Python implemented application. My teacher want me to create DLL file of IronPython implemented application. I don't know how to begin. Please help me. Thank you. All the best. _________________________________________________________________ Boo!?Scare away worms, viruses and so much more! Try Windows Live OneCare! http://onecare.live.com/standard/en-us/purchase/trial.aspx?s_cid=wl_hotmailnews -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071106/edf0f4a4/attachment.htm From lists at cheimes.de Tue Nov 6 19:38:00 2007 From: lists at cheimes.de (Christian Heimes) Date: Tue, 06 Nov 2007 19:38:00 +0100 Subject: [Python.NET] What can I do with DLL? In-Reply-To: References: Message-ID: <4730B488.20301@cheimes.de> jane janet wrote: > I'm a student. I wanna know how to do about my project. > I implemented aplication using Ironpython because I have to use .NET library and c# code but I also have to use this application with another Python implemented application. My teacher want me to create DLL file of IronPython implemented application. I don't know how to begin. Please help me. If you really want to develop with IronPython you are on the wrong list. PythonDotNet is about integrating .NET assemblies in CPython applications or vice versa. Using IronPython and PythonDotNet in the same application isn't a task for a student's project. I'm sorry but that's far too complex. It may be task for a diploma or master topic. You'd need intimate knowledge of the C implementation of Python, the C# implementation of IronPython plus extended knowledge of C, C#, .NET reflections and other technologies. You have to understand how to deal with pointers and direct memory manipulation in C#. It's non trivial in C and it's even more complex with .NET and C#. In my opinion as PythonDotNet sustentative developer and CPython core developer your professor is asking too much. You'd have a fair chance to develop an assembly (DLL) with C# and use it in CPython using PythonDotNet or you could develop everything with IronPython. A useful and high-performance apps combining both technologies it out of scope for a student without extensive knowledge about CPython and IronPython. I myself wouldn't do it and I've developed parts of PythonDotNet and Python 3000. Christian From hsu.feihong at yahoo.com Tue Nov 6 22:16:22 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Tue, 6 Nov 2007 13:16:22 -0800 (PST) Subject: [Python.NET] Can I create extension file by C#? In-Reply-To: Message-ID: <709799.55837.qm@web34801.mail.mud.yahoo.com> Just make an ordinary C# class, then when you compile it make sure to use the /target:library switch. Once it's inside a .DLL file, you can use that class from IronPython. C# file (Example.cs): using System; namespace Example { public class ExampleClass { public void ExampleMethod(int i, string s, DateTime dt) { Console.WriteLine("{0}, {1}, {2}", i, s, dt); } } } To compile, run this at the command line (or just compile it in Visual C#): csc /target:library Example.cs You will get a file named Example.dll. The IronPython file (example.py): import clr clr.AddReference('Example') from System import DateTime from Example import ExampleClass e = ExampleClass() e.ExampleMethod(45, "hello", DateTime.Today) Make sure that example.py is in the same directory as Example.dll (otherwise make sure the directory of Example.dll is in sys.path). BTW, I had problems getting this example working in IronPython 2.0 Alpha 4, I used IronPython 1.1 instead. - Feihong jane janet wrote: .hmmessage P { margin:0px; padding:0px } body.hmmessage { FONT-SIZE: 10pt; FONT-FAMILY:Tahoma } Hello all, I wanna to know that can i create any extension file or DLL file by using C# and if it can I wanna know how to do too. Please help me. Thank you. --------------------------------- Peek-a-boo FREE Tricks & Treats for You! Get 'em!_________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071106/43aa3208/attachment.htm From anakinnani at hotmail.com Wed Nov 14 11:36:56 2007 From: anakinnani at hotmail.com (jane janet) Date: Wed, 14 Nov 2007 10:36:56 +0000 Subject: [Python.NET] Python Extension in C#? Message-ID: Hello all, Please tell me how can I create .dll for Python in C#? Every advice would be great. Thank you. All the best, _________________________________________________________________ Windows Live Hotmail and Microsoft Office Outlook ? together at last. ?Get it now. http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071114/68a0d939/attachment.htm From jhargraveiii at comcast.net Sun Nov 18 06:10:57 2007 From: jhargraveiii at comcast.net (Jim) Date: Sat, 17 Nov 2007 22:10:57 -0700 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... Message-ID: My python is 2.4 UCS4 on Ubuntu 7.10. I was able to build the Python.Runtime.dll. I used the pre-built clr.so (wouldn't build) and copied it to /usr/lib/python2.4/site-packages. I also built a special python2.4 dynamically linked to libpython. I copied Python.Runtime.dll to /usr/bin (same location as my python2.4), but when try "import clr" I get the error "Assemblies not found". However when I launch python2.4 in the same directory as Python.Runtime.dll the "import clr" works without error. Alsp clrpython2.4 crashes unless I launch it in the same directory is Python.Runtime.dll. Obviously python is not finding my Python.Runtime.dll. Where should this file be copied so that it can be found no matter where python is launched? J From sanxiyn at gmail.com Sun Nov 18 06:17:11 2007 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Sun, 18 Nov 2007 14:17:11 +0900 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: References: Message-ID: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> 2007/11/18, Jim : > Obviously python is not finding my Python.Runtime.dll. Where should this > file be copied so that it can be found no matter where python is launched? You should install it to the Global Assembly Cache(GAC). $ gacutil -i Python.Runtime.dll -- Seo Sanghyeon From lists at cheimes.de Sun Nov 18 19:46:29 2007 From: lists at cheimes.de (Christian Heimes) Date: Sun, 18 Nov 2007 19:46:29 +0100 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> References: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> Message-ID: Sanghyeon Seo wrote: > You should install it to the Global Assembly Cache(GAC). > > $ gacutil -i Python.Runtime.dll In order to install an assembly in the GAC it must have a strong name. I've signed the assemblies in the preview zip. As far as I remember they can be installed to the GAC, too. However I recommend against the GAC. Only stable assemblies with a fixed api should be installed in the GAC. I don't consider a beta as stable enough. For Mono you can use the env var MONO_PATH. Christian From jhargraveiii at comcast.net Mon Nov 19 00:02:10 2007 From: jhargraveiii at comcast.net (Jim) Date: Sun, 18 Nov 2007 16:02:10 -0700 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: References: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> Message-ID: I set MONO_PATH export MONO_PATH=/usr/lib/mono/python2.4 I place Python.Runtime.dll in the dir above. import clr says the assembles still can't be found. J Christian Heimes wrote: > Sanghyeon Seo wrote: > > You should install it to the Global Assembly Cache(GAC). >> $ gacutil -i Python.Runtime.dll > > In order to install an assembly in the GAC it must have a strong name. > I've signed the assemblies in the preview zip. As far as I remember they > can be installed to the GAC, too. > > However I recommend against the GAC. Only stable assemblies with a fixed > api should be installed in the GAC. I don't consider a beta as stable > enough. For Mono you can use the env var MONO_PATH. > > Christian > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From JBurnett at blizzard.com Mon Nov 19 01:48:58 2007 From: JBurnett at blizzard.com (John Burnett) Date: Sun, 18 Nov 2007 16:48:58 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? References: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> Message-ID: <44055E60E3A2174080A3086D5CD4D0390275A4F7@BL-EXCHANGE.corp.blizzard.net> I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (ie. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071118/3d991fd6/attachment.htm From JBurnett at blizzard.com Mon Nov 19 02:09:17 2007 From: JBurnett at blizzard.com (John Burnett) Date: Sun, 18 Nov 2007 17:09:17 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? Message-ID: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> (re-posting to break it out of the Ubuntu thread... my bad, sorry) I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... John -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071118/a2f5f352/attachment.htm From lists at cheimes.de Mon Nov 19 02:38:01 2007 From: lists at cheimes.de (Christian Heimes) Date: Mon, 19 Nov 2007 02:38:01 +0100 Subject: [Python.NET] Added 64-bit support, delegates/events broken? In-Reply-To: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> Message-ID: <4740E8F9.7050904@cheimes.de> John Burnett wrote: > I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. Neither Brian nor me have a 64bit CPU. Although the code tries to be 64bit compatible neither of us is able to verify the code. Thanks for your work! :) You cannot check in the code yourself. Can you please make two patches, one for the 64bit and one for the unit tests, and post them in the bug and feature tracker at sf.net? Brian: I still don't have developer and technician roles in the bug tracker. Can you please raise my level for the tracker, too? > That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... I haven't seen hard crashes for a while. I'm using VS 2005 and Mono 1.2.4 for testing. Please post some details. Christian From jhargraveiii at comcast.net Mon Nov 19 09:11:32 2007 From: jhargraveiii at comcast.net (Jim) Date: Mon, 19 Nov 2007 01:11:32 -0700 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: References: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> Message-ID: <47414534.3070600@comcast.net> Still never got the dynamically linked python2.4 to find the assemblies Python.Runtime. Updating MONO_PATH didn't work. I ended up taking the C# version python.exe and wrapping it with a shell script called python2.4 - underneath looks like "mono python.exe" This version seems to understand MONO_PATH. If anybody knows how to get the native version of python (built under monoclr) please let me know. Jim Jim wrote: > I set MONO_PATH > > export MONO_PATH=/usr/lib/mono/python2.4 > > I place Python.Runtime.dll in the dir above. > > import clr says the assembles still can't be found. > > J > > > Christian Heimes wrote: >> Sanghyeon Seo wrote: >> > You should install it to the Global Assembly Cache(GAC). >>> $ gacutil -i Python.Runtime.dll >> In order to install an assembly in the GAC it must have a strong name. >> I've signed the assemblies in the preview zip. As far as I remember they >> can be installed to the GAC, too. >> >> However I recommend against the GAC. Only stable assemblies with a fixed >> api should be installed in the GAC. I don't consider a beta as stable >> enough. For Mono you can use the env var MONO_PATH. >> >> Christian >> >> _________________________________________________ >> Python.NET mailing list - PythonDotNet at python.org >> http://mail.python.org/mailman/listinfo/pythondotnet >> > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From hsu.feihong at yahoo.com Mon Nov 19 16:14:11 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Mon, 19 Nov 2007 07:14:11 -0800 (PST) Subject: [Python.NET] Added 64-bit support, delegates/events broken? In-Reply-To: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> Message-ID: <727103.11575.qm@web34802.mail.mud.yahoo.com> Are you talking about Python.NET 1.0 or 2.0? I still haven't tried Python.NET 2.0 on my 64-bit workstation, but 1.0 crashes when I try to use Interop assemblies. I'm not seeing any problems in 1.0 with respect to delegates/events on x64. - Feihong John Burnett wrote: Added 64-bit support, delegates/events broken? (re-posting to break it out of the Ubuntu thread... my bad, sorry) I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... John _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071119/3ad8dbe1/attachment.htm From JBurnett at blizzard.com Mon Nov 19 20:53:10 2007 From: JBurnett at blizzard.com (John Burnett) Date: Mon, 19 Nov 2007 11:53:10 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? In-Reply-To: <727103.11575.qm@web34802.mail.mud.yahoo.com> References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> <727103.11575.qm@web34802.mail.mud.yahoo.com> Message-ID: <44055E60E3A2174080A3086D5CD4D03902D55DDA@BL-EXCHANGE.corp.blizzard.net> I'm talking about Python.NET 2.0. Regardless, you're using the 32-bit version of Python on your machine, right? import platform platform.architecture() John From: Feihong Hsu [mailto:hsu.feihong at yahoo.com] Sent: Monday, November 19, 2007 7:14 AM To: John Burnett; pythondotnet at python.org Subject: Re: [Python.NET] Added 64-bit support, delegates/events broken? Are you talking about Python.NET 1.0 or 2.0? I still haven't tried Python.NET 2.0 on my 64-bit workstation, but 1.0 crashes when I try to use Interop assemblies. I'm not seeing any problems in 1.0 with respect to delegates/events on x64. - Feihong John Burnett wrote: (re-posting to break it out of the Ubuntu thread... my bad, sorry) I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... John _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet ________________________________ Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071119/5aeab631/attachment.htm From JBurnett at blizzard.com Mon Nov 19 21:01:37 2007 From: JBurnett at blizzard.com (John Burnett) Date: Mon, 19 Nov 2007 12:01:37 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> <4740E8F9.7050904@cheimes.de> Message-ID: <44055E60E3A2174080A3086D5CD4D03902D55DE2@BL-EXCHANGE.corp.blizzard.net> Re-sending to get it posted to the maillist (really don't know how these work, or how the threading is determined under http://mail.python.org/pipermail/pythondotnet/2007-November/thread.html ). ---- Ok, I've submitted the patches. Note that I'm purely Windows here using the Microsoft .NET framework, so I'm not sure what the fallout is on mono or other platforms. The meat of the changes boils down to two lines in the clrmodule file, but I gotta say it was fun getting back to the IL:). That said, here's the details for the two crashes I'm seeing: My 32-bit machine is running XP Pro, and my 64-bit machine is running Vista64 Business. Both machines have VS2005 and VS2008beta2 installed, so I have .NET frameworks 2.0, 3.0, and 3.5. In runtests.py, the two offending scripts are 'test_event' and 'test_delegate' (lines 36 and 38). I have to comment out one to see the other run, since they both cause hard crashes in python.exe with an unhandled exception. In all cases below, I'm running the precompiled python 2.5.1 downloaded from python.org. For the 32-bit runs, I'm using a release build of clr.pyd that I compiled under VS2005 from a download of pythonnet-2.0-alpha2.zip from SourceForge. For the 64-bit runs, I'm running a release build of clr.pyd compiled under VS2005 based on the patches I just submitted. The "only" difference between the 32-bit and 64-bit exception traces is that the 64-bit version has an extra entry in the call stack (a call to Python.Runtime.CodeGenerator.DefineType(String name, Type basetype)). Any ideas, or need any additional details that I can provide? :) Cheers, John **** 32-bit, test_event **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr handler) at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg) **************************** **** 64-bit, test_event **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.CodeGenerator.DefineType(String name, Type basetype) at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr handler) at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg) **************************** **** 32-bit, test_delegate **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args, IntPtr kw) at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr ) at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw) **************************** **** 64-bit, test_delgate **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.CodeGenerator.DefineType(String name, Type basetype) at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args, IntPtr kw) at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr ) at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw) **************************** -----Original Message----- From: Christian Heimes [mailto:lists at cheimes.de] Sent: Sunday, November 18, 2007 5:38 PM To: John Burnett Cc: Brian Lloyd Subject: Re: [Python.NET] Added 64-bit support, delegates/events broken? John Burnett wrote: > I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. Neither Brian nor me have a 64bit CPU. Although the code tries to be 64bit compatible neither of us is able to verify the code. Thanks for your work! :) You cannot check in the code yourself. Can you please make two patches, one for the 64bit and one for the unit tests, and post them in the bug and feature tracker at sf.net? Brian: I still don't have developer and technician roles in the bug tracker. Can you please raise my level for the tracker, too? > That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... I haven't seen hard crashes for a while. I'm using VS 2005 and Mono 1.2.4 for testing. Please post some details. Christian From JBurnett at blizzard.com Tue Nov 20 04:27:52 2007 From: JBurnett at blizzard.com (John Burnett) Date: Mon, 19 Nov 2007 19:27:52 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net> <4740E8F9.7050904@cheimes.de> Message-ID: <44055E60E3A2174080A3086D5CD4D03902D55E6D@BL-EXCHANGE.corp.blizzard.net> ....aaand one more note: I just re-made the patch (now at http://sourceforge.net/tracker/index.php?func=detail&aid=1834903&group_i d=162464&atid=823893 ). I basically re-wrote clrmodule.il. It's heavily commented now, and supports loading out of PYTHONPATH (based on idea by Maksim Kozyarchuk). It only does this as a fallback if Python.Runtime can't be found using standard assembly resolution rules (which is the default, so no behavior "should" have changed for already working installs). There's also #ifdef'd code in there to make clr.pyd more tightly bound to Python.Runtime if/when Python.Runtime gets a final version and/or strong name. John -----Original Message----- From: John Burnett Sent: Monday, November 19, 2007 12:02 PM To: pythondotnet at python.org Subject: RE: [Python.NET] Added 64-bit support, delegates/events broken? Re-sending to get it posted to the maillist (really don't know how these work, or how the threading is determined under http://mail.python.org/pipermail/pythondotnet/2007-November/thread.html ). From JBurnett at blizzard.com Wed Nov 21 04:06:47 2007 From: JBurnett at blizzard.com (John Burnett) Date: Tue, 20 Nov 2007 19:06:47 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? In-Reply-To: <44055E60E3A2174080A3086D5CD4D03902D55DE2@BL-EXCHANGE.corp.blizzard.net> References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net><4740E8F9.7050904@cheimes.de> <44055E60E3A2174080A3086D5CD4D03902D55DE2@BL-EXCHANGE.corp.blizzard.net> Message-ID: <44055E60E3A2174080A3086D5CD4D03902D55EB8@BL-EXCHANGE.corp.blizzard.net> If anyone is looking at this delegates/events thing, I have a cargo-cult style fix that "seems to" work, sorta. Gory details follow, and I'm not comfortable saying "it's fixed!" because I really don't know what's going on below. I'd love it if someone could help: CodeGenerator is currently a static class, and it's only used by the static DelegateManager. In turn, DelegateManager is only used a couple times by EventObject and DelegateObject. Since the crashes are occurring inside the static ctor of CodeGenerator, I made it a non-static type, along with DelegateManager. (I gave DelegateManager a private instance of CodeGenerator, and gave Python.Runtime.PythonEngine a public instance of DelegateManager that's created in PythonEngine.Initialize. Event/DelegateObject were then updated to use that public instance). That all done, the ctor of CodeGenerator then ran fine on import, and no crashes occurred. However, after that I'm getting a few "Decref(NULL)" prints during the test runs. Each of them is happening inside a Python.Runtime.PythonException.Dispose() call. I'm calling "Console.WriteLine(Runtime.PyObject_Repr(this.PyType));" in those Dispose calls for info, and the three exceptions are: "TypeError : handler() takes exactly 6 arguments (3 given)" "TypeError : handler() takes exactly 2 arguments (3 given)" "TypeError : unbound method handler() must be called with GenericHandler instance as first argument (got EventTest instance instead)" ...and all seem to be coming from the test_delegate suite running under either cpython 2.5.1, or the wrapped console from python.net. Not sure if those are expected? Lastly, for a few more clues, I initially kept everything above static, and gave CodeGenerator a public static Init method that PythonEngine.InitExt called (along with all CodeGenerator methods, just for grins). The Init method only ran once (a la "if(!init){init=true;...}"). The odd thing that then happened during test runs was this: **** Load clr import hook PythonEngine.InitExt running PythonEngine.Initialize called PythonEngine.Initialize running CodeGenerator.Init called CodeGenerator.Init running ...................................................................E............ ................................................................................ .........................................CodeGenerator.Init called CodeGenerator.Init running Unhandled Exception: System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. **** ...notice CodeGenerator.Init never completed running the first time, but the tests kept going. Further debug prints show it was happening on the line "aBuilder = Thread.GetDomain().DefineDynamicAssembly(aname, aa);" in CodeGenerator's static ctor (same place the other crashes were happening). I'm guessing there is an exception happening there, but it's getting eaten somewhere above. That all said... help? Brian? Christian? :) John -----Original Message----- From: pythondotnet-bounces+jburnett=blizzard.com at python.org [mailto:pythondotnet-bounces+jburnett=blizzard.com at python.org] On Behalf Of John Burnett Sent: Monday, November 19, 2007 12:02 PM To: pythondotnet at python.org Subject: Re: [Python.NET] Added 64-bit support, delegates/events broken? Re-sending to get it posted to the maillist (really don't know how these work, or how the threading is determined under http://mail.python.org/pipermail/pythondotnet/2007-November/thread.html ). ---- Ok, I've submitted the patches. Note that I'm purely Windows here using the Microsoft .NET framework, so I'm not sure what the fallout is on mono or other platforms. The meat of the changes boils down to two lines in the clrmodule file, but I gotta say it was fun getting back to the IL:). That said, here's the details for the two crashes I'm seeing: My 32-bit machine is running XP Pro, and my 64-bit machine is running Vista64 Business. Both machines have VS2005 and VS2008beta2 installed, so I have .NET frameworks 2.0, 3.0, and 3.5. In runtests.py, the two offending scripts are 'test_event' and 'test_delegate' (lines 36 and 38). I have to comment out one to see the other run, since they both cause hard crashes in python.exe with an unhandled exception. In all cases below, I'm running the precompiled python 2.5.1 downloaded from python.org. For the 32-bit runs, I'm using a release build of clr.pyd that I compiled under VS2005 from a download of pythonnet-2.0-alpha2.zip from SourceForge. For the 64-bit runs, I'm running a release build of clr.pyd compiled under VS2005 based on the patches I just submitted. The "only" difference between the 32-bit and 64-bit exception traces is that the 64-bit version has an extra entry in the call stack (a call to Python.Runtime.CodeGenerator.DefineType(String name, Type basetype)). Any ideas, or need any additional details that I can provide? :) Cheers, John **** 32-bit, test_event **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr handler) at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg) **************************** **** 64-bit, test_event **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.CodeGenerator.DefineType(String name, Type basetype) at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.EventObject.AddEventHandler(IntPtr target, IntPtr handler) at Python.Runtime.EventBinding.nb_inplace_add(IntPtr ob, IntPtr arg) **************************** **** 32-bit, test_delegate **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args, IntPtr kw) at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr ) at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw) **************************** **** 64-bit, test_delgate **** Unhandled Exception: System.TypeInitializationException: The type initializer for 'Python.Runtime.CodeGenerator' threw an exception. ---> System.InvalidCastException: Unable to cast object of type 'System.Reflection.Module' to type 'System.Reflection.Emit.ModuleBuilder'. at System.Reflection.Emit.AssemblyBuilderData.GetInMemoryAssemblyModule() at System.AppDomain.InternalDefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access, String dir, Evidence evidence, PermissionSet requiredPermissions, PermissionSet optionalPermissions, PermissionSet refusedPermissions, StackCrawlMark& stackMark, IEnumerable`1 unsafeAssemblyAttributes) at System.AppDomain.DefineDynamicAssembly(AssemblyName name, AssemblyBuilderAccess access) at Python.Runtime.CodeGenerator..cctor() --- End of inner exception stack trace --- at Python.Runtime.CodeGenerator.DefineType(String name, Type basetype) at Python.Runtime.DelegateManager.GetDispatcher(Type dtype) at Python.Runtime.DelegateManager.GetDelegate(Type dtype, IntPtr callable) at Python.Runtime.DelegateObject.tp_new(IntPtr tp, IntPtr args, IntPtr kw) at e__NativeCall.Call_3(IntPtr , IntPtr , IntPtr , IntPtr ) at Python.Runtime.MetaType.tp_call(IntPtr tp, IntPtr args, IntPtr kw) **************************** -----Original Message----- From: Christian Heimes [mailto:lists at cheimes.de] Sent: Sunday, November 18, 2007 5:38 PM To: John Burnett Cc: Brian Lloyd Subject: Re: [Python.NET] Added 64-bit support, delegates/events broken? John Burnett wrote: > I've made a few changes necessary to make python.net 64-bit compatible. I can check in the changes on Monday (unless I need an account set up first?) I also fixed a broken test case wrt. exceptions. Neither Brian nor me have a 64bit CPU. Although the code tries to be 64bit compatible neither of us is able to verify the code. Thanks for your work! :) You cannot check in the code yourself. Can you please make two patches, one for the 64bit and one for the unit tests, and post them in the bug and feature tracker at sf.net? Brian: I still don't have developer and technician roles in the bug tracker. Can you please raise my level for the tracker, too? > That said, I'm getting unrelated hard crashes when running the test cases for either events or delegates (i.e. the whole test harness crashes out). Is anyone else seeing this, or is it something peculiar with my setup (it's happening in both 32 and 64 bit Vista, compiled under VS2005). I can post details on Monday if necessary... I haven't seen hard crashes for a while. I'm using VS 2005 and Mono 1.2.4 for testing. Please post some details. Christian _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet From JBurnett at blizzard.com Wed Nov 21 20:59:53 2007 From: JBurnett at blizzard.com (John Burnett) Date: Wed, 21 Nov 2007 11:59:53 -0800 Subject: [Python.NET] Added 64-bit support, delegates/events broken? In-Reply-To: <44055E60E3A2174080A3086D5CD4D03902D55EB8@BL-EXCHANGE.corp.blizzard.net> References: <44055E60E3A2174080A3086D5CD4D0390275A4F8@BL-EXCHANGE.corp.blizzard.net><4740E8F9.7050904@cheimes.de><44055E60E3A2174080A3086D5CD4D03902D55DE2@BL-EXCHANGE.corp.blizzard.net> <44055E60E3A2174080A3086D5CD4D03902D55EB8@BL-EXCHANGE.corp.blizzard.net> Message-ID: <44055E60E3A2174080A3086D5CD4D03902D55EEA@BL-EXCHANGE.corp.blizzard.net> Last spam on this from me until I hear back, promise :) I just submitted the "fix" for delegate support I outlined before. http://sourceforge.net/tracker/index.php?func=detail&aid=1836026&group_id=162464&atid=823893 Again, not sure this is actually masking some bad behavior elsewhere, but it seems to make python.net actually work for me here, so I'm submitting anyway. John From jigisbert.etra-id at grupoetra.com Fri Nov 23 14:28:21 2007 From: jigisbert.etra-id at grupoetra.com (Jose Ignacio Gisbert) Date: Fri, 23 Nov 2007 14:28:21 +0100 Subject: [Python.NET] Pithon.net or iron python?? Message-ID: <001801c82dd4$bbd67590$2000a8c0@depid.local> Hi all, I am developing an application which Graphic interface is in C#, but I want to call methods in some situations (when press certain button ) that are coded in Python. First, it can be possible to mix both languages?, and second, What should I do, use Iron Python or Pithon.net?. Sorry for my ignorance. Thanks in advance _______________________________ Jos? Ignacio Gisbert Sanus -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071123/298736e3/attachment.htm From hsu.feihong at yahoo.com Fri Nov 23 15:07:38 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Fri, 23 Nov 2007 06:07:38 -0800 (PST) Subject: [Python.NET] Pithon.net or iron python?? In-Reply-To: <001801c82dd4$bbd67590$2000a8c0@depid.local> Message-ID: <692445.26572.qm@web34806.mail.mud.yahoo.com> Yes, it is possible to "mix" C# and Python. You can have Python use classes and methods defined in a .NET assembly (DLL file), or you can create the PythonEngine object in your C# code and run Python scripts using that. There's no way to answer the second question without knowing more details. The most important question is what kind of Python scripts are being called. IronPython is currently unable to deal with certain Python libraries. You might find that some of the your Python scripts won't run in IronPython. - Feihong Jose Ignacio Gisbert wrote: Hi all, I am developing an application which Graphic interface is in C#, but I want to call methods in some situations (when press certain button ) that are coded in Python. First, it can be possible to mix both languages?, and second, What should I do, use Iron Python or Pithon.net?. Sorry for my ignorance. Thanks in advance _______________________________ Jos? Ignacio Gisbert Sanus _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071123/dc5533d0/attachment.htm From jhargraveiii at comcast.net Sun Nov 18 07:29:51 2007 From: jhargraveiii at comcast.net (jimh) Date: Sat, 17 Nov 2007 23:29:51 -0700 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> References: <5b0248170711172117v7c6f7ec3t1cd2609f2a58805e@mail.gmail.com> Message-ID: <473FDBDF.700@comcast.net> Running this command I get the error: "Attempt to install an Assembly without a strong name" Sanghyeon Seo wrote: > 2007/11/18, Jim : > >> Obviously python is not finding my Python.Runtime.dll. Where should this >> file be copied so that it can be found no matter where python is launched? >> > > You should install it to the Global Assembly Cache(GAC). > > $ gacutil -i Python.Runtime.dll > > From lists at cheimes.de Sun Nov 18 19:49:44 2007 From: lists at cheimes.de (Christian Heimes) Date: Sun, 18 Nov 2007 19:49:44 +0100 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: References: Message-ID: <47408948.8060806@cheimes.de> Jim wrote: > My python is 2.4 UCS4 on Ubuntu 7.10. I was able to build the > Python.Runtime.dll. I used the pre-built clr.so (wouldn't build) and > copied it to /usr/lib/python2.4/site-packages. I also built a special > python2.4 dynamically linked to libpython. Why doesn't clr.so build for you? Have you installed the mono and python developer packages? $ sudo apt-get install libmono-dev python2.4-dev Christian From lists at cheimes.de Sun Nov 18 20:54:36 2007 From: lists at cheimes.de (Christian Heimes) Date: Sun, 18 Nov 2007 20:54:36 +0100 Subject: [Python.NET] Configuration on Ubuntu: Assembly not found error... In-Reply-To: <47409684.5010504@comcast.net> References: <47408948.8060806@cheimes.de> <47409684.5010504@comcast.net> Message-ID: <4740987C.3020704@cheimes.de> jimh wrote: > Yes both the dev packages are installed. Here's the error I get. > /usr/bin/python2.4 setup.py build_ext -i > /usr/bin/python2.4: can't open file 'setup.py': [Errno 2] No such file > or directory > > I don't see a setup.py in the package on sourceforge. Oh yeah, I see the problem. The setup.py file isn't in the package. I forgot to add it. You can grab the file from subversion. Christian From matt.mackowski at slipg8.com Tue Nov 27 20:20:55 2007 From: matt.mackowski at slipg8.com (Matt Mackowski) Date: Tue, 27 Nov 2007 11:20:55 -0800 Subject: [Python.NET] bridging C# and Python Message-ID: Hi, I would like to run a python application have it call a C# application and have the two applications be able to call functions in the other application. I have gotten the python to open and run the C# application and I am able to run any function from the C# app in python. What I am having trouble with is calling python functions from the C# when the C# app was started by a python call. When I run the C# alone I can call the python functions. Part of my problem I think is that the C# app doesn't know where to fine the python modules. Where do they need to be if I want to use the PythonEngine.ImportModule? In python my codes looks like this import clr import pythoncom clr.AddReference("ScriptEditor") from ScriptEditor import ScriptEditor self.app = ScriptEditor() clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Application Application.Run(self.app) ScriptEditor is my C# app. I can call most of the C# functions from python with the above code. The C# functions I cannot call are ones that use python for example //---------------------------------------------------------------------- --------------------------- public void usingPython() //---------------------------------------------------------------------- --------------------------- { PythonEngine.Initialize(); IntPtr pyLock = PythonEngine.AcquireLock(); PyObject pyObj = PythonEngine.ImportModule("hello"); pyObj.InvokeMethod("helloCallback", new PyTuple()); PythonEngine.ReleaseLock(pyLock); PythonEngine.Shutdown(); } That doesn't work. It works when I call the function in C#. Hello.py looks like this: def hello(): return 'hello' def helloCallback(): print "This is a Test and Of The python.net" Thanks Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071127/1d9b878c/attachment.htm From brian.lloyd at revolutionhealth.com Wed Nov 28 17:02:18 2007 From: brian.lloyd at revolutionhealth.com (Brian Lloyd) Date: Wed, 28 Nov 2007 11:02:18 -0500 Subject: [Python.NET] bridging C# and Python In-Reply-To: Message-ID: Python modules just need to be somewhere on the pythonpath (sys.path). You should probably be careful how crazy you get with python calling C# calling back into python, etc. - its fairly easy to get into a deadlock situation that way due to the python global interpreter lock... -Brian On 11/27/07 2:20 PM, "Matt Mackowski" wrote: > Hi, > > I would like to run a python application have it call a C# application and > have the two applications be able to call functions in the other application. > I have gotten the python to open and run the C# application and I am able to > run any function from the C# app in python. > > What I am having trouble with is calling python functions from the C# when the > C# app was started by a python call. When I run the C# alone I can call the > python functions. > > Part of my problem I think is that the C# app doesn?t know where to fine the > python modules. Where do they need to be if I want to use the > PythonEngine.ImportModule? > > In python my codes looks like this > > import clr > import pythoncom > clr.AddReference("ScriptEditor") > from ScriptEditor import ScriptEditor > self.app = ScriptEditor() > clr.AddReference("System.Windows.Forms") > from System.Windows.Forms import Application > Application.Run(self.app) > > ScriptEditor is my C# app. > I can call most of the C# functions from python with the above code. The C# > functions I cannot call are ones that use python for example > > //---------------------------------------------------------------------------- > --------------------- > public void usingPython() > //---------------------------------------------------------------------------- > --------------------- > { > PythonEngine.Initialize(); > IntPtr pyLock = PythonEngine.AcquireLock(); > PyObject pyObj = PythonEngine.ImportModule("hello"); > > pyObj.InvokeMethod("helloCallback", new PyTuple()); > > PythonEngine.ReleaseLock(pyLock); > PythonEngine.Shutdown(); > } > > That doesn?t work. It works when I call the function in C#. > Hello.py looks like this: > > def hello(): > return 'hello' > > def helloCallback(): > print "This is a Test and Of The python.net" > > Thanks > > Matt > > > _________________________________________________ > Python.NET mailing list - PythonDotNet at python.org > http://mail.python.org/mailman/listinfo/pythondotnet -------------------------- Brian Lloyd brian.lloyd at revolutionhealth.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071128/d9cc3ae6/attachment.htm From hsu.feihong at yahoo.com Wed Nov 28 17:25:33 2007 From: hsu.feihong at yahoo.com (Feihong Hsu) Date: Wed, 28 Nov 2007 08:25:33 -0800 (PST) Subject: [Python.NET] bridging C# and Python In-Reply-To: Message-ID: <302959.25048.qm@web34803.mail.mud.yahoo.com> Have you tried using callbacks through delegates instead? In practice I haven't had any problems doing stuff like that. For example the following works fine: def callback(sender, args): print 'You clicked on', sender.Text btn = Button() btn.Text = 'Click me!' btn.Click += callback Doing it this way means the C# code doesn't need to worry about how to find any Python modules. - Feihong Matt Mackowski wrote: Hi, I would like to run a python application have it call a C# application and have the two applications be able to call functions in the other application. I have gotten the python to open and run the C# application and I am able to run any function from the C# app in python. What I am having trouble with is calling python functions from the C# when the C# app was started by a python call. When I run the C# alone I can call the python functions. Part of my problem I think is that the C# app doesn?t know where to fine the python modules. Where do they need to be if I want to use the PythonEngine.ImportModule? In python my codes looks like this import clr import pythoncom clr.AddReference("ScriptEditor") from ScriptEditor import ScriptEditor self.app = ScriptEditor() clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Application Application.Run(self.app) ScriptEditor is my C# app. I can call most of the C# functions from python with the above code. The C# functions I cannot call are ones that use python for example //------------------------------------------------------------------------------------------------- public void usingPython() //------------------------------------------------------------------------------------------------- { PythonEngine.Initialize(); IntPtr pyLock = PythonEngine.AcquireLock(); PyObject pyObj = PythonEngine.ImportModule("hello"); pyObj.InvokeMethod("helloCallback", new PyTuple()); PythonEngine.ReleaseLock(pyLock); PythonEngine.Shutdown(); } That doesn?t work. It works when I call the function in C#. Hello.py looks like this: def hello(): return 'hello' def helloCallback(): print "This is a Test and Of The python.net" Thanks Matt _________________________________________________ Python.NET mailing list - PythonDotNet at python.org http://mail.python.org/mailman/listinfo/pythondotnet --------------------------------- Get easy, one-click access to your favorites. Make Yahoo! your homepage. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071128/5c93839a/attachment.htm From petyuk at gmail.com Thu Nov 29 22:44:13 2007 From: petyuk at gmail.com (Vladislav Petyuk) Date: Thu, 29 Nov 2007 13:44:13 -0800 Subject: [Python.NET] accessing managed VB.NET dll Message-ID: I'm sorry for such a basic question, but I can not find an answer on it in the mail archive or manual. I have a VB dll which uses .NET and I need to instantiate a certain class and call a certain method. It sounds like clr, since its a managed dll, would be a right library to use. So what is the right way to do this? I was successful in using ctypes for calling functions from native C dlls, but it seems not to work this time (or I'm missing something). Thanks, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20071129/33717b35/attachment.htm