From Steffen.Guhlemann at mailbox.tu-dresden.de Mon Aug 2 10:30:42 2004 From: Steffen.Guhlemann at mailbox.tu-dresden.de (Steffen Guhlemann) Date: Tue Aug 3 15:19:50 2004 Subject: [Python.NET] compiling IronPython Message-ID: <1091435442.410dfbb2bedbc@rmc60-231.urz.tu-dresden.de> Hi, i tried it - and in Interpretermodus everything worked fine. But did anybody find out, how the "advertised" compiling to native IL is supposed to work? ciao Steffen > Hi! > > Probably you all know IronPython (been vapourware a long time)... now > you can find on IronPythons homepage, http://www.ironpython.com, an > alpha version of it (means version 0.6). > > I've only tested it under Windows, with both .NET Framework 1.1 and Mono > 1.0 and it seems to work. Well, untill no it is not as mature as > CPython, but I've got Windows.Forms running without errors. > > greets, > Marek From philmc at gmail.com Wed Aug 4 06:44:17 2004 From: philmc at gmail.com (Phil McCluskey) Date: Wed Aug 4 06:44:20 2004 Subject: [Python.NET] compiling IronPython In-Reply-To: <1091435442.410dfbb2bedbc@rmc60-231.urz.tu-dresden.de> References: <1091435442.410dfbb2bedbc@rmc60-231.urz.tu-dresden.de> Message-ID: <87de4a20408032144622ad571@mail.gmail.com> I think the file called __main__.exe is the compiled script. On Mon, 2 Aug 2004 10:30:42 +0200, Steffen Guhlemann wrote: > Hi, > > i tried it - and in Interpretermodus everything worked fine. But did anybody > find out, how the "advertised" compiling to native IL is supposed to work? > > ciao Steffen > > Hi! > > > > Probably you all know IronPython (been vapourware a long time)... now > > you can find on IronPythons homepage, http://www.ironpython.com, an > > alpha version of it (means version 0.6). > > > > I've only tested it under Windows, with both .NET Framework 1.1 and Mono > > 1.0 and it seems to work. Well, untill no it is not as mature as > > CPython, but I've got Windows.Forms running without errors. > > > > greets, > > Marek > > _________________________________________________ > Python.NET mailing list - PythonDotNet@python.org > http://mail.python.org/mailman/listinfo/pythondotnet > -- Cheers, Phil From thane at magna-capital.com Wed Aug 4 23:14:10 2004 From: thane at magna-capital.com (Thane) Date: Wed Aug 4 23:14:15 2004 Subject: [Python.NET] compiling IronPython In-Reply-To: <1091435442.410dfbb2bedbc@rmc60-231.urz.tu-dresden.de> Message-ID: Use the "-O" switch: IronPythonConsole -O MyPythonFile.py Creates __main__.exe from the Python source in MyPythonFile.py. --Thane -----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org] On Behalf Of Steffen Guhlemann Sent: Monday, August 02, 2004 1:31 AM To: pythondotnet@python.org Subject: [Python.NET] compiling IronPython Hi, i tried it - and in Interpretermodus everything worked fine. But did anybody find out, how the "advertised" compiling to native IL is supposed to work? ciao Steffen > Hi! > > Probably you all know IronPython (been vapourware a long time)... now > you can find on IronPythons homepage, http://www.ironpython.com, an > alpha version of it (means version 0.6). > > I've only tested it under Windows, with both .NET Framework 1.1 and Mono > 1.0 and it seems to work. Well, untill no it is not as mature as > CPython, but I've got Windows.Forms running without errors. > > greets, > Marek _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet From gyrepin at techie.com Thu Aug 5 20:31:26 2004 From: gyrepin at techie.com (Sam Iredale) Date: Thu Aug 5 20:31:30 2004 Subject: [Python.NET] Embedded scripting Message-ID: <000001c47b1a$6b0348c0$80420504@samihome> I'm trying to embed Python for application scripting in my C# solution. I've managed to load the Python module form C#; but how do I get the Python script to call back into the application? The "from MODULE import CLASS" semantics throw an exception here; and I think it's because the class being called is in the same process (not in a dll). Here's the test C# code: using System; using Python.Runtime; namespace PyTest { /// /// Summary description for Class1. /// public class PyTestClass { PyObject module = null; public PyTestClass() { PythonEngine.Initialize(); } ~PyTestClass() { PythonEngine.Finalize(); } public void PyMessage() { Console.WriteLine("PyMessage() has been called."); } /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { PyTestClass pyTest = new PyTestClass(); try { if(!PythonEngine.IsInitialized) throw new Exception("PythonEngine not initialized."); pyTest.module = PythonEngine.ImportModule("PyTest"); } catch(Exception e) { Console.WriteLine(e.Message); Console.Write(e.StackTrace); } } } } And the Python script: from PyTest.PyTest import PyTestClass def test(): print "testing." PyTestClass.PyMessage() test(); I know the embedding is working; because when the module is loaded, if I comment out the import line and the call to the PyTestClass in the script, the string "testing." is output to the console. But once I put in the stuff that calls back into the C# code, it throws a PythonException. Any ideas? Thanks, SI From brian at zope.com Thu Aug 5 21:49:19 2004 From: brian at zope.com (Brian Lloyd) Date: Thu Aug 5 21:49:37 2004 Subject: [Python.NET] Embedded scripting In-Reply-To: <000001c47b1a$6b0348c0$80420504@samihome> Message-ID: Hi Sam - I think the problem is the import line in your Python script: from PyTest.PyTest import PyTestClass should be: import CLR # for safety due to a deep import issue from CLR.PyTest.PyTest import PyTestClass IOW, all imports from managed code come from the magic top-level 'CLR' module. Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces@python.org > [mailto:pythondotnet-bounces@python.org]On Behalf Of Sam Iredale > Sent: Thursday, August 05, 2004 1:31 PM > To: pythondotnet@python.org > Subject: [Python.NET] Embedded scripting > > > I'm trying to embed Python for application scripting in my C# solution. > I've managed to load the Python module form C#; but how do I get the > Python script to call back into the application? The "from MODULE import > CLASS" semantics throw an exception here; and I think it's because the > class being called is in the same process (not in a dll). > > Here's the test C# code: > > using System; > using Python.Runtime; > > namespace PyTest > { > /// > /// Summary description for Class1. > /// > public class PyTestClass > { > PyObject module = null; > > public PyTestClass() > { > PythonEngine.Initialize(); > } > ~PyTestClass() > { > PythonEngine.Finalize(); > } > > public void PyMessage() > { > Console.WriteLine("PyMessage() has been > called."); > } > > /// > /// The main entry point for the application. > /// > [STAThread] > static void Main(string[] args) > { > PyTestClass pyTest = new PyTestClass(); > > try > { > if(!PythonEngine.IsInitialized) > throw new > Exception("PythonEngine not initialized."); > pyTest.module = > PythonEngine.ImportModule("PyTest"); > } > catch(Exception e) > { > Console.WriteLine(e.Message); > Console.Write(e.StackTrace); > } > } > } > } > > And the Python script: > > from PyTest.PyTest import PyTestClass > def test(): > print "testing." > PyTestClass.PyMessage() > test(); > > > I know the embedding is working; because when the module is loaded, if I > comment out the import line and the call to the PyTestClass in the > script, the string "testing." is output to the console. But once I put > in the stuff that calls back into the C# code, it throws a > PythonException. Any ideas? > > Thanks, > SI > > _________________________________________________ > Python.NET mailing list - PythonDotNet@python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From gyrepin at techie.com Fri Aug 6 04:22:49 2004 From: gyrepin at techie.com (Sam Iredale) Date: Fri Aug 6 04:22:52 2004 Subject: [Python.NET] Embedded scripting In-Reply-To: Message-ID: <000001c47b5c$454d5480$80420504@samihome> Good idea; but it didn't work. :P I also tried changing the import line AND changing the name of my namespace to CLR.PyTest. But to no avail. Would the import line even work with a class that's part of the exe that initialized the Python interpreter; or am I barking up the wrong tree? Thanks, SI -----Original Message----- From: Brian Lloyd [mailto:brian@zope.com] Sent: Thursday, August 05, 2004 12:49 PM To: Sam Iredale; pythondotnet@python.org Subject: RE: [Python.NET] Embedded scripting Hi Sam - I think the problem is the import line in your Python script: from PyTest.PyTest import PyTestClass should be: import CLR # for safety due to a deep import issue from CLR.PyTest.PyTest import PyTestClass IOW, all imports from managed code come from the magic top-level 'CLR' module. Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com > -----Original Message----- > From: pythondotnet-bounces@python.org > [mailto:pythondotnet-bounces@python.org]On Behalf Of Sam Iredale > Sent: Thursday, August 05, 2004 1:31 PM > To: pythondotnet@python.org > Subject: [Python.NET] Embedded scripting > > > I'm trying to embed Python for application scripting in my C# > solution. I've managed to load the Python module form C#; but how do I > get the Python script to call back into the application? The "from > MODULE import CLASS" semantics throw an exception here; and I think > it's because the class being called is in the same process (not in a > dll). > > Here's the test C# code: > > using System; > using Python.Runtime; > > namespace PyTest > { > /// > /// Summary description for Class1. > /// > public class PyTestClass > { > PyObject module = null; > > public PyTestClass() > { > PythonEngine.Initialize(); > } > ~PyTestClass() > { > PythonEngine.Finalize(); > } > > public void PyMessage() > { > Console.WriteLine("PyMessage() has been > called."); > } > > /// > /// The main entry point for the application. > /// > [STAThread] > static void Main(string[] args) > { > PyTestClass pyTest = new PyTestClass(); > > try > { > if(!PythonEngine.IsInitialized) > throw new > Exception("PythonEngine not initialized."); > pyTest.module = > PythonEngine.ImportModule("PyTest"); > } > catch(Exception e) > { > Console.WriteLine(e.Message); > Console.Write(e.StackTrace); > } > } > } > } > > And the Python script: > > from PyTest.PyTest import PyTestClass > def test(): > print "testing." > PyTestClass.PyMessage() > test(); > > > I know the embedding is working; because when the module is loaded, if > I comment out the import line and the call to the PyTestClass in the > script, the string "testing." is output to the console. But once I put > in the stuff that calls back into the C# code, it throws a > PythonException. Any ideas? > > Thanks, > SI > > _________________________________________________ > Python.NET mailing list - PythonDotNet@python.org > http://mail.python.org/mailman/listinfo/pythondotnet > From gyrepin at techie.com Fri Aug 6 07:56:04 2004 From: gyrepin at techie.com (Sam Iredale) Date: Fri Aug 6 07:56:06 2004 Subject: [Python.NET] Making progress on embedding. Message-ID: <000001c47b7a$0f6fd3b0$80420504@samihome> Still working on the problem of embedding Python for application scripting in a C# project. I'm having problems getting the Python script to call back into the C# code, though the application successfully loads the Python script module. My C# code has evolved to this: using System; using Python.Runtime; namespace PyTest { /// /// Summary description for Class1. /// public class PyTestClass { public PyObject module = null; public PyTestClass() { PythonEngine.Initialize(); } ~PyTestClass() { PythonEngine.Finalize(); } /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { try { PyTestClass pyTest = new PyTestClass(); if(!PythonEngine.IsInitialized) throw new Exception("PythonEngine not initialized."); pyTest.module = PythonEngine.ImportModule("PyTest"); } catch(Exception e) { Console.WriteLine(e.Message); Console.Write(e.StackTrace); } } } public class PyTestInterface { public PyTestInterface() { // do nothing, just making a public constructor } public void PyTestMsg() { Console.WriteLine("Test Pass!"); } } } And my Python script has evolved to this: import CLR from CLR.PyTest import PyTestInterface def test(): print "testing." obj=PyTestInterface() obj.PyMessage() test() Any help would be ... well ... very ... helpful. Thanks, SI From garth at deadlybloodyserious.com Fri Aug 6 09:02:03 2004 From: garth at deadlybloodyserious.com (Garth T Kidd) Date: Fri Aug 6 09:02:14 2004 Subject: [Python.NET] IronPython: trying to build assemblies and call them from other .Net modules Message-ID: <20040806070210.1EC4F5E62C@mail03.your-site.com> Anyone lucked out on this one? Figuring snippets.dll is the output assembly and adding a reference to it, I can browse IronPython's classes if I have a class defined in the Python code I just ran. I can't, however, see the class I defined. :| Regards, Garth. From lists at hugunin.net Mon Aug 9 06:53:19 2004 From: lists at hugunin.net (Jim Hugunin) Date: Mon Aug 9 07:01:22 2004 Subject: [Python.NET] IronPython: trying to build assemblies and call themfrom other .Net modules In-Reply-To: <20040806070210.1EC4F5E62C@mail03.your-site.com> Message-ID: <20040809050120.6C6EB1E4002@bag.python.org> Hi all, I'm sorry that I set expectations too high with my note about static compilation on the ironpython web page. This is a feature that can and should work well, but today it is only barely there. I've updated the web page to make it clear that this feature isn't really working in 0.6. To see the state-of-the-art today, make a very simple Python script, like hello.py (with 'print "hello world" in it). Then run it by passing it to IronPythonConsole. After you run it, there should be a file "__main__.exe" in the appropriate directory. You should be able to run this file now as a stand-alone executable. Also, I've finally set up a users@ironpython.com mailing list where these messages can be sent in the future so that they can benefit the greatest number of people. You can subscribe here. http://lists.ironpython.com/listinfo.cgi/users-ironpython.com Let's leave this mailing list for discussion of Brian's excellent tool (which is already at 1.0betaX). Sorry for any confusion - Jim -----Original Message----- From: pythondotnet-bounces@python.org [mailto:pythondotnet-bounces@python.org] On Behalf Of Garth T Kidd Sent: Friday, August 06, 2004 12:02 AM To: pythondotnet@python.org Subject: [Python.NET] IronPython: trying to build assemblies and call themfrom other .Net modules Anyone lucked out on this one? Figuring snippets.dll is the output assembly and adding a reference to it, I can browse IronPython's classes if I have a class defined in the Python code I just ran. I can't, however, see the class I defined. :| Regards, Garth. _________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet From gyrepin at techie.com Mon Aug 9 23:28:56 2004 From: gyrepin at techie.com (Sam Iredale) Date: Mon Aug 9 23:29:16 2004 Subject: [Python.NET] Application scripting - Embedding/Extending Python. solution Message-ID: <000001c47e57$e0ec65e0$80420504@samihome> I got it working. Here's my sample code: using System; using Python.Runtime; namespace PyTest { /// /// Summary description for Class1. /// class PyTestClass { PyObject module = null; PyObject func = null; PyTestClass() { PythonEngine.Initialize(); } ~PyTestClass() { PythonEngine.Finalize(); } void Scratch() { } /// /// The main entry point for the application. /// [STAThread] static void Main(string[] args) { try { // initiliaze the engine PyTestClass pyTest = new PyTestClass(); if(!PythonEngine.IsInitialized) throw new Exception("PythonEngine not initialized."); // load the module and the dictionary pyTest.module = PythonEngine.ImportModule("PyTest"); // get a reference to the function named "test" from the Python script pyTest.func = pyTest.module.GetAttr((string) "test"); // if the reference we got in the above call in callable, call it. if(pyTest.func.IsCallable()) { PyObject[] obj = new PyObject[1]; // an array of objects representing the function arguments PyTuple tup; // we'll pass the arguments to the funciton in a tuple // convert our string into a PyObject and place it in the array obj[0] = PyObject.FromManagedObject((string) "Embedding and Extending."); // convert the array of PyObjects into a single PyTuple tup = new PyTuple(obj); // call the Ivoke method of the funciton reference with the tuple containing // the function arguements. pyTest.func.Invoke(tup); } } catch(Exception e) { Console.WriteLine(e.Message); Console.Write(e.StackTrace); } } } public class PyTestInterface { public PyTestInterface() { // do nothing, just making a public constructor } public void PyTestMsg(string testname) { Console.WriteLine("Test Pass! " + testname); } } } And here's the sample Python script: import CLR # gives this Python script access to managed namespaces from CLR.System.Reflection import Assembly # for importing managed assemblies asm = Assembly.LoadWithPartialName("PyTest.exe") from CLR.PyTest import PyTestInterface # mports the interface for this applicaiton iface = PyTestInterface() def test(str): print "testing:" iface.PyTestMsg(str) print "test finished."; test("Extending") I hope this helps someone out there. There are certainly a number of ways this can be done. But this specific approach leads me in the direction I need to go in order to solve the problems I want to solve. SI From scl at protronic.com Fri Aug 13 09:50:11 2004 From: scl at protronic.com (COOL Steven) Date: Fri Aug 13 15:20:54 2004 Subject: [Python.NET] PythonNet crashes Message-ID: <1FE21036A81C804DBD1A5EEAAA99FD1B2987B5@pic01s51.picanol.be> Hello I've downloaded and unpacked the PythonNet 1.0, beta 3. When I try to run Python.exe, I get an unhandled-exception window. then, I tried to copy the clr.dll and the python.runtime.dll to my existing python directory. when I try to import CLR.System, I get the same error. Anybody knows what goes wrong here? regards Steven Cool Protronic NV Rozendaalstraat 53 BE-8900 Ieper P: + 32 (0)57 22 47 09 E-mail: steven.cool@protronic.be **** DISCLAIMER **** The contents of this e-mail are intended for the named addressee only. It contains information which may be confidential and which may also be privileged. Unless you are the named addressee (or authorised to receive for the addressee) you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. Further, we make every effort to keep our network free from viruses. However, you do need to verify that this email and any attachments are free of viruses as we can take no responsibility for any computer virus which might be transferred by way of this e-mail. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/pythondotnet/attachments/20040813/df0fbde0/attachment.htm From zunzun at zunzun.com Sat Aug 14 21:28:59 2004 From: zunzun at zunzun.com (James R. Phillips) Date: Tue Aug 17 15:21:21 2004 Subject: [Python.NET] Runs OK on Linux with Mono Message-ID: <411e67fb01a5e4.53936020@mercury.sabren.com> Python For .NET beta 3 runs fine for me with Mono version 1.01 on Linux. I do get "free(): invalid pointer" messages, presumably from garbage collection (??) but it does seem to run fine. James Phillips http://zunzun.com From brian at zope.com Tue Aug 17 17:00:43 2004 From: brian at zope.com (Brian Lloyd) Date: Tue Aug 17 17:01:24 2004 Subject: [Python.NET] Runs OK on Linux with Mono In-Reply-To: <411e67fb01a5e4.53936020@mercury.sabren.com> Message-ID: > Python For .NET beta 3 runs fine for me with Mono > version 1.01 on Linux. I do get "free(): invalid pointer" > messages, presumably from garbage collection (??) > but it does seem to run fine. > > James Phillips > http://zunzun.com Thats great news ;) It also confirms that there is still a bug lurking somewhere in my interop-level memory mgmt (I've gotten reports of invalid frees under a debugger on win32 as well...) Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com