Re: [Pyobjc-dev] Don't want to ship sources
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-06-27 18:02:29
|
Sorry to burst your bubble here... but any serious python developer that actually wants to see what your code does isn't going to have a problem doing so.. python compilation is a nearly reversible operation because the "assembly language" it basically has an opcode for each kind of syntax token, in-line documentation is preserved (except in .pyo), and the names of local scope variables (including function arguments) don't go away. Hell, you don't even lose LINE NUMBERS in compiled code. from input like this: def code(): heres_my_secret = 1234 heres_my_secret *= 4 return heres_my_secret | 2 Using the dis module that comes with python, you get output like this: >>> dis.disassemble(secret.code.func_code) 2 0 LOAD_CONST 1 (1234) 3 STORE_FAST 0 (heres_my_secret) 3 6 LOAD_FAST 0 (heres_my_secret) 9 LOAD_CONST 2 (4) 12 INPLACE_MULTIPLY 13 STORE_FAST 0 (heres_my_secret) 4 16 LOAD_FAST 0 (heres_my_secret) 19 LOAD_CONST 3 (2) 22 BINARY_OR 23 RETURN_VALUE 24 LOAD_CONST 0 (None) 27 RETURN_VALUE The number of parameters, names of parameters, keyword arguments, etc can be read from members of the secret.code function object.. The numbers to the left (2, 3, 4) correspond to line numbers in the secret.py file. It's rather easy to see that if you knew enough about this stuff you could write a disassembler that would output something nearly identical to the input code. The real question is what the heck do you have that is so proprietary that you can't trust your users not to break the law. It's not like you're even selling a consumer product (from what I could glean from your company's website). -bob On Friday, Jun 27, 2003, at 09:59 America/New_York, Bob Swerdlow wrote: > For anyone who is interested: I discovered the "compileall" module > (http://www.python.org/doc/current/lib/module-compileall.html) that > allowed > me to build the application the way I wanted. I just added it to the > top of > buildapp.py and changed the suffixes to *.pyc. > > From: "Bob Swerdlow" <rsw...@tr...> > To: <pyo...@li...> > Date: Thu, 26 Jun 2003 13:56:42 -0400 > Subject: [Pyobjc-dev] Don't want to ship sources > > Has anyone tried to create a PyObjC application that includes only > compiled > files rather than Python sources scripts? I'm preparing a PyObjC > application for distribution and we don't want to ship the source > files. > I've found that I can just change the buildapp.py to include *.pyc > files and > everything works fine - except that the python interpreter doesn't > want to > give me compiled files for every class. > > So, my question is - is there a way to force python to create compiled > files > for each class? My approach has been to add this code to the > buildapp.py > file: > > liststrFiles = [ fn[0 : len(fn-len(".py")] for fn in > os.listdir('.') if > fn.endswith('.py') and fn not in ('buildapp.py', "myApp.py") ] > for str in lststrFiles: > exec("import " + str) > > srcs = [ fn for fn in os.listdir('.') if fn.endswith(".pyc") ] > > and then to add srcs to the resources line in buildapp(). I don't > include > the main script "myApp.py" since python gets confused about the NIB > stuff. > > Anyway, this approach doesn't work because not all of the files get > compiled > into *.pyc files. Is there any way to force this or is there another > approach to building the app without sources? > > Thanks, > > Bob Swerdlow > COO > Transpose > rsw...@tr... > 207-781-8284 > http://www.transpose.com |