<s> import os <EOL> import sys <EOL> import stat <EOL> import subprocess <EOL> from cx_Freeze import Executable , Freezer , setup <EOL> import lxtools <EOL> from cx_Freeze import main <EOL> srcdir = '<STR_LIT:.>' <EOL> distdir = os . path . join ( srcdir , '<STR_LIT>' ) <EOL> iconfile = os . path . join ( srcdir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> scriptFiles = [ <EOL> os . path . join ( srcdir , '<STR_LIT>' ) <EOL> ] <EOL> if os . path . exists ( distdir ) : <EOL> lxtools . rmDirectory ( distdir ) <EOL> executables = { } <EOL> for scriptFile in scriptFiles : <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> ex = Executable ( <EOL> scriptFile , <EOL> icon = iconfile , <EOL> appendScriptToExe = True , <EOL> ) <EOL> else : <EOL> ex = Executable ( <EOL> scriptFile , <EOL> ) <EOL> executables [ ex ] = True <EOL> f = Freezer ( <EOL> executables , <EOL> excludes = [ ] , <EOL> targetDir = distdir , <EOL> copyDependentFiles = True , <EOL> compress = False , <EOL> ) <EOL> f . Freeze ( ) <EOL> if sys . platform == '<STR_LIT>' : <EOL> print ( "<STR_LIT>" ) <EOL> shippedfiles = os . listdir ( distdir ) <EOL> for file in shippedfiles : <EOL> filepath = os . path . join ( distdir , file ) <EOL> mode = os . stat ( filepath ) . st_mode <EOL> if not ( mode & stat . S_IWUSR ) : <EOL> os . chmod ( filepath , mode | stat . S_IWUSR ) <EOL> subprocess . call ( ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' + file , filepath ) ) <EOL> otool = subprocess . Popen ( ( '<STR_LIT>' , '<STR_LIT>' , filepath ) , stdout = subprocess . PIPE ) <EOL> libs = otool . stdout . readlines ( ) <EOL> for lib in libs : <EOL> lib = lib . decode ( ) <EOL> filename , _ , _ = lib . strip ( ) . partition ( '<STR_LIT:U+0020>' ) <EOL> prefix , name = os . path . split ( filename ) <EOL> if name in shippedfiles : <EOL> newfilename = '<STR_LIT>' + name <EOL> print ( '<STR_LIT>' % ( name , newfilename ) ) <EOL> subprocess . call ( ( '<STR_LIT>' , '<STR_LIT>' , filename , newfilename , filepath ) ) <EOL> print ( "<STR_LIT>" ) </s>
