[IronPython] Two Problems with sys.argv and compiled scripts

Michael Foord fuzzyman at voidspace.org.uk
Mon Mar 23 23:54:49 CET 2009


Bruce Bromberek wrote:
> So if I follow your lead at 
> http://www.voidspace.org.uk/ironpython/custom_executable.shtml
>
> it looks like I need to modify this code to call my complied DLL 
> instead of the pythonsource code?
>             string path = Path.Combine(
>                 Path.GetDirectoryName(Application.ExecutablePath),
>                                       "main.py");
>             engine.ExecuteFile(path);
>
>   
> Is that right?  My end goal it to produce an exe that I can wrap up 
> into an installer and distribute to people without ironpython installed.
>
> Once I get a working example, I'll post a detailed explanation back to 
> this group for the benefit of the others coping with the transition 
> from IronPython 1.0 to 2.0.
>

That article is for IronPython 1 as it says at the start. It sounds like 
that is what you want.

If you want IronPython 2 then you are better off with this article:

http://www.voidspace.org.uk/ironpython/hosting_api.shtml

All the best,

Michael Foord

>
> Thanks in advance
>
>
> -WombatPM
>
> PS  If you tell me that your book has all of the detail, I'll get the 
> early access version ASAP.
>
>
>
>
> On Mon, Mar 23, 2009 at 4:16 PM, Michael Foord 
> <fuzzyman at voidspace.org.uk <mailto:fuzzyman at voidspace.org.uk>> wrote:
>
>     Bruce Bromberek wrote:
>
>         Problem #1
>         I know this is a know issue, but my google-fu has been able to
>         uncover the solution.  When I compile my script into an exe ,
>         sys.argv get sets to ' '.
>
>         Using SharpDevelop and Ironpython 2.0.1
>
>         #Program.py
>         #
>         import clr
>         clr.AddReference('mscorlib')
>         clr.AddReference('System')
>         import sys
>         import System
>
>         if __name__ == 'Program':
>            try:
>                print "sys.argv = ",sys.argv
>            except System.Exception, e:
>                print e
>
>         yeilds output of
>         C:\Program Files\IronPython 2.0.1\Samples\pyc>Program.exe fred
>         sys.argv =  ['']
>
>         instead of the expected
>         sys.argv['fred']
>
>         Problem #2:
>
>         If I drag and drop a file onto the exe, I get a exception
>         message that I can't see.  In IronPython 1.0, the dropped file
>         would populate sys.argv
>
>         Hopefully someone can answer or direct me to better source.
>
>
>
>     Creating a custom C# executable that embeds the IronPython engine,
>     starts your application, and populates sys.argv is the best
>     workaround for these problems.
>
>     Michael
>
>
>         -WombatPM
>
>
>         ------------------------------------------------------------------------
>
>         _______________________________________________
>         Users mailing list
>         Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>         http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>          
>
>
>
>     -- 
>     http://www.ironpythoninaction.com/
>     http://www.voidspace.org.uk/blog
>
>
>     _______________________________________________
>     Users mailing list
>     Users at lists.ironpython.com <mailto:Users at lists.ironpython.com>
>     http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog





More information about the Ironpython-users mailing list