<s> """<STR_LIT>""" <EOL> import compileall <EOL> import os <EOL> import setuptools <EOL> import shutil <EOL> import sys <EOL> PWD = os . path . dirname ( os . path . realpath ( __file__ ) ) <EOL> APP_NAME = "<STR_LIT:foo>" <EOL> APP_VERSION = "<STR_LIT:1.0>" <EOL> APP_SCRIPT_NAME = "<STR_LIT>" % APP_NAME . lower ( ) <EOL> def get_py2app_options ( ) : <EOL> try : <EOL> import PySide <EOL> PyQt4 = None <EOL> except ImportError : <EOL> PySide = None <EOL> try : <EOL> import PyQt4 <EOL> except ImportError : <EOL> exit ( - <NUM_LIT:1> ) <EOL> python_qt = PySide or PyQt4 <EOL> qt_gui = "<STR_LIT>" % python_qt . __name__ <EOL> qt_core = "<STR_LIT>" % python_qt . __name__ <EOL> packages = [ "<STR_LIT>" ] <EOL> includes = [ "<STR_LIT>" , qt_gui , qt_core ] <EOL> excludes = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> if PyQt4 : <EOL> pyqt_excludes = [ "<STR_LIT>" , "<STR_LIT>" , '<STR_LIT>' , "<STR_LIT>" , <EOL> "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> "<STR_LIT>" ] <EOL> excludes . extend ( pyqt_excludes ) <EOL> else : <EOL> pyside_excludes = [ "<STR_LIT>" ] <EOL> excludes . extend ( pyside_excludes ) <EOL> frameworks = [ <EOL> "<STR_LIT>" , <EOL> ] <EOL> py2app_options = { <EOL> "<STR_LIT>" : packages , <EOL> "<STR_LIT>" : includes , <EOL> "<STR_LIT>" : excludes , <EOL> "<STR_LIT>" : frameworks , <EOL> } <EOL> return py2app_options <EOL> plist = dict ( <EOL> CFBundleName = APP_NAME , <EOL> CFBundleShortVersionString = APP_VERSION , <EOL> CFBundleGetInfoString = '<STR_LIT:U+0020>' . join ( [ APP_NAME , APP_VERSION ] ) , <EOL> CFBundleExecutable = APP_NAME , <EOL> CFBundleIdentifier = '<STR_LIT>' % APP_NAME , <EOL> ) <EOL> data_files = [ <EOL> ( "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ] <EOL> def _create_app ( ) : <EOL> app_option = [ <EOL> { <EOL> "<STR_LIT>" : APP_SCRIPT_NAME , <EOL> "<STR_LIT>" : plist , <EOL> } <EOL> ] <EOL> setuptools . setup ( <EOL> name = APP_NAME , <EOL> version = APP_VERSION , <EOL> description = "<STR_LIT>" , <EOL> author = "<STR_LIT>" , <EOL> author_email = "<STR_LIT>" , <EOL> platforms = [ "<STR_LIT>" ] , <EOL> license = "<STR_LIT>" , <EOL> url = "<STR_LIT>" , <EOL> scripts = [ APP_SCRIPT_NAME ] , <EOL> packages = setuptools . find_packages ( exclude = ( "<STR_LIT>" , ) ) , <EOL> app = app_option , <EOL> options = { '<STR_LIT>' : get_py2app_options ( ) } , <EOL> data_files = data_files , <EOL> ) <EOL> APP_RESOURCES_PATH = os . path . join ( PWD , '<STR_LIT>' , '<STR_LIT>' % APP_NAME . lower ( ) , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def delete_old_app ( ) : <EOL> BUILD_PATH = os . path . join ( PWD , "<STR_LIT>" ) <EOL> DIST_PATH = os . path . join ( PWD , "<STR_LIT>" ) <EOL> if os . path . exists ( BUILD_PATH ) : <EOL> shutil . rmtree ( BUILD_PATH ) <EOL> if os . path . exists ( DIST_PATH ) : <EOL> shutil . rmtree ( DIST_PATH ) <EOL> def compile_py ( ) : <EOL> compileall . compile_dir ( PWD ) <EOL> _QT_CONF_TPL = """<STR_LIT:U+0020>""" <EOL> def patch_qt_conf ( ) : <EOL> dst = os . path . join ( APP_RESOURCES_PATH , '<STR_LIT>' ) <EOL> f = file ( dst , "<STR_LIT:w>" ) <EOL> f . write ( _QT_CONF_TPL ) <EOL> f . close ( ) <EOL> def package_app_for_mac ( ) : <EOL> delete_old_app ( ) <EOL> compile_py ( ) <EOL> _create_app ( ) <EOL> patch_qt_conf ( ) <EOL> def print_help ( ) : <EOL> msg = "<STR_LIT>" + "<STR_LIT:\n>" <EOL> msg += "<STR_LIT:\t>" + "<STR_LIT>" + "<STR_LIT:\n>" <EOL> sys . stdout . write ( msg ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> args = sys . argv [ <NUM_LIT:1> : ] <EOL> if len ( args ) < <NUM_LIT:2> : <EOL> print_help ( ) <EOL> elif args [ <NUM_LIT:0> ] == "<STR_LIT>" and args [ <NUM_LIT:1> ] == "<STR_LIT>" : <EOL> package_app_for_mac ( ) <EOL> else : <EOL> print_help ( ) </s>
