5

I am making an app in python on mac osx 10.8.5 I converted the python script into an app by using py2app. But, within app, On Show Package Contents-->Contents-->Resources original code is present. I don't want to show my code to others by distributing my app as security issue. I removed the (.py)code with (.pyc)code, in that case the app didn't work properly. Please suggest some way for it.I search on other questions also, but didn't get the desired result. My setup.py is

from setuptools import setup

APP=['myapp.py']
DATA_FILES= [('',['config.cfg'])]
OPTIONS={'iconfile':'cc.icns','argv_emulation': True,'plist':{'CFBundleShortVersionString':'1.0'}}

setup(
    app=APP,
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app']
    ) 
imp
  • 1,967
  • 2
  • 28
  • 40

1 Answers1

1

The easiest workaround is to move the code in myapp.py to another module and import that module in myapp.py.

Note that modules other than the main script are only byte-compiled (as .pyc files), and those files can still easily be turned into source code.

Byte-compiling the script file is on my todo list, but is more complicated that just replacing a .py file by a .pyc file as you noticted :-)

Ronald Oussoren
  • 2,715
  • 20
  • 29
  • Is there any other way of doing it. I want more security. While importing module, there is error showing in time.sleep(2) as 'Attribute error" : 'NoneType' object has no attribute sleep – imp Nov 02 '13 at 08:46
  • "I want more security." - Be aware there is no such thing as 'secure' code. You can obfuscate it, compile it, write it in any language you like, but if someone cares enough to find out what's in it, they can always decompile and unobfuscate it again. Even a simple `strings` command will let them extract any human-readable text. The most you can hope for is to make the effort of prying more trouble than it's worth. – foo Nov 02 '13 at 22:09
  • @foo ok While importing module, there is error showing in time.sleep(2) as 'Attribute error" : 'NoneType' object has no attribute sleep, have idea why it is showing – imp Nov 03 '13 at 17:51