From: Marko L. <mar...@gm...> - 2013-02-12 10:59:49
|
Hello, Is there a way to make a py2exe compiled code execute a non-compiled python code (without installing python)? The idea is let part of the code non-compiled to allow the users to easily make some changes. They have windows non-admin access to their machine so in principle they can't install python. Thanks for any hint! Cheers, Marko |
From: Werner F. B. <wer...@fr...> - 2013-02-12 11:15:41
|
Hi Marko, On 12/02/2013 11:59, Marko Loparic wrote: > Hello, > > Is there a way to make a py2exe compiled code execute a non-compiled > python code (without installing python)? > > The idea is let part of the code non-compiled to allow the users to > easily make some changes. They have windows non-admin access to their > machine so in principle they can't install python. > > Thanks for any hint! Cheers, A py2exe'd app includes pythonxx.dll and other things needed by Python and whatever your app uses. I never needed this but I think/guess (pretty sure:) that should just work, i.e. if you have a "mymodule.py" within e.g. your package and then your py2exe'd app imports this it will just work. Have you tried it, are you getting any error? Werner |
From: Marko L. <mar...@gm...> - 2013-02-12 17:30:24
|
On Tue, Feb 12, 2013 at 12:16 PM, Werner F. Bruhin wrote: > > Hi Marko, > > On 12/02/2013 11:59, Marko Loparic wrote: > > Hello, > > > > Is there a way to make a py2exe compiled code execute a non-compiled > > python code (without installing python)? > > > > The idea is let part of the code non-compiled to allow the users to > > easily make some changes. They have windows non-admin access to their > > machine so in principle they can't install python. > > > > Thanks for any hint! Cheers, > A py2exe'd app includes pythonxx.dll and other things needed by Python > and whatever your app uses. > > I never needed this but I think/guess (pretty sure:) that should just > work, i.e. if you have a "mymodule.py" within e.g. your package and then > your py2exe'd app imports this it will just work. It works! > Have you tried it, are you getting any error? Actually I hadn't, sorry, I hadn't figured out it could be so easy... All I needed to do was to append sys.path as Thomas said. Now I understand better what py2exe does. This is wonderful news for me, thanks a lot Werner and Thomas for the help! Marko |
From: Thomas H. <th...@ct...> - 2013-02-12 11:31:21
|
Am 12.02.2013 11:59, schrieb Marko Loparic: > Hello, > > Is there a way to make a py2exe compiled code execute a non-compiled > python code (without installing python)? > > The idea is let part of the code non-compiled to allow the users to > easily make some changes. They have windows non-admin access to their > machine so in principle they can't install python. You should add the directory that contains the module to sys.path, then you can import it. Thomas |
From: Fahlgren, E. <efa...@li...> - 2013-02-12 17:25:47
|
Marko, You have lots of options, with one already presented (augment sys.path and use import). Here are a couple more that I've used: Execute an argument containing source supplied on the commmand line: mycode.exe -c 'print "hello" ; import math ; print math.sqrt(2)' gns = dictionary of global symbols I want to expose, e.g., globals() code = compile(args.command+'\n', "command line", "exec") exec(code, gns) Collect the name of the file that the users wants executed and simply execute it: filename = "usercode.py" execfile(filename, gns) The first example is very general, get some source in a string, compile it and execute it. The second is really just shorthand for doing exactly that. HTH, Eric From: Marko Loparic [mailto:mar...@gm...] Sent: Tuesday, February 12, 2013 02:59 To: py2...@li... Subject: [Py2exe-users] Execute non-compiled code from a py2exe executable Hello, Is there a way to make a py2exe compiled code execute a non-compiled python code (without installing python)? The idea is let part of the code non-compiled to allow the users to easily make some changes. They have windows non-admin access to their machine so in principle they can't install python. Thanks for any hint! Cheers, Marko |