Newbie Win32 Questions

Eugene Goodrich bitbucket at isomedia.com
Fri Jan 7 21:33:24 EST 2000


There is something I've heard of called "freeze" that I believe makes
an executable that is a combination the python interpreter, your
script, and anything else required, all bundled together.  While this
might solve the problem of installing python on all the client
machines, I'd guess it comes with a file size cost that might mean you
wouldn't want to do this with a lot of scripts.

Plus, virtually every computer should have Python installed on it,
anyway.

Preventing prying eyes is altogether different.  Why don't you want
people to see your code?  Are you surreptitiously collecting data on
your users' music listening habits and sending it to yourself?

Anyway, when you import python libraries (i.e. import foo), Python
compiles the imported file (foo.pyc).  Successive imports will load
from the .pyc version until changes to the .py version require a
recompile.  So you can write a dummy script that imports your "real"
script and fires it up, then distribute just the compiled version of
the "real" script.

Or, you could make your script self-compiling, like the following
(self_compiler.py).  Run "self_compiler.py COMPILE" to make it compile
itself into self._compiler.pyc.  You can distribute self_compiler.pyc
to the people with the crowbars in their faces (provided they have
Python installed, of course), and they can run that.  I don't know how
hard it would be to de-compile your .pyc file, but I'm guessing it's
not impossible, since Python is a powerful, interactive, interpreted
language.

self_compiler.py:
->>>
import sys

class fooClass:
	def __init__ (self):
		print 'Initializing instance variables and stuff.'
		print 'Finished initializing.'
	def run (self):
		print 'Running...'
		print 'Finished.'

if len (sys.argv) > 1:
	if sys.argv[1] == 'COMPILE':
		if __name__ == '__main__':
			print 'Compiling myself.'
			import self_compiler
		sys.exit ()
oObject = fooClass ()
oObject.run ()
-<<<

    -Eugene

On Fri, 07 Jan 2000 21:42:04 GMT, tuttled at my-deja.com wrote:

>
>
>Help please. I've got a couple of questions I
>haven't been able to find any answers to.
>
>1) Can you make a stand alone app? Meaning is
>there a way to compile and distribute one or more
>files without having to install Python on every
>machine you want to run the app on?
>
>2) If not, how do protect source code from prying
>eyes?
>
>TIA,
>Don
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.

import binascii; print binascii.a2b_base64 ('ZXVnZW5lQGlzb21lZGlhLmNvbQ==')



More information about the Python-list mailing list