Skip to content

Commit

Permalink
Merge pull request #129 from fuzzball81/pep8-cleanup
Browse files Browse the repository at this point in the history
Pep8 cleanup
  • Loading branch information
Sput42 committed Jul 1, 2015
2 parents 24900ee + b241006 commit 6c1008c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
build*
*.pyc
tags
23 changes: 8 additions & 15 deletions scripts/build/macosx_DeployApp.py
Expand Up @@ -32,10 +32,8 @@
"""




class InstallQt(object):
def __init__(self, appdir, bundle = True, requestedPlugins=[]):
def __init__(self, appdir, bundle=True, requestedPlugins=[]):
self.appDir = appdir
self.bundle = bundle
self.frameworkDir = self.appDir + "/Frameworks"
Expand All @@ -52,7 +50,6 @@ def __init__(self, appdir, bundle = True, requestedPlugins=[]):
for executable in executables:
self.resolveDependancies(executable)


self.findPluginsPath()
self.installPlugins(requestedPlugins)
self.installQtConf()
Expand Down Expand Up @@ -101,7 +98,6 @@ def findPlugin(self, pluginname):
raise OSError
return result


def installPlugins(self, requestedPlugins):
try:
os.mkdir(self.pluginDir)
Expand Down Expand Up @@ -145,7 +141,7 @@ def installQtConf(self):

def resolveDependancies(self, obj):
# obj must be either an application binary or a framework library
#print "resolving deps for:", obj
# print "resolving deps for:", obj
for framework, lib in self.determineDependancies(obj):
self.installFramework(framework)
self.changeDylPath(obj, framework, lib)
Expand Down Expand Up @@ -185,14 +181,14 @@ def installFramework(self, framework):
except:
libname = ''
otoolProcess.stdout.close()
if otoolProcess.wait() == 1: # we found some Resource dir or similar -> skip
if otoolProcess.wait() == 1: # we found some Resource dir or similar -> skip
continue
frameworkpath, libpath = libname.split(frameworkname)
if self.bundle:
newlibname = "@executable_path/../%s%s" % (frameworkname, libpath)
else:
newlibname = "@executable_path/%s%s" % (frameworkname, libpath)
#print 'install_name_tool -id "%s" "%s"' % (newlibname, lib)
# print 'install_name_tool -id "%s" "%s"' % (newlibname, lib)
os.system('install_name_tool -id "%s" "%s"' % (newlibname, lib))

self.resolveDependancies(lib)
Expand All @@ -201,22 +197,19 @@ def determineDependancies(self, app):
otoolPipe = Popen('otool -L "%s"' % app, shell=True, stdout=PIPE).stdout
otoolOutput = [line for line in otoolPipe]
otoolPipe.close()
libs = [line.split()[0] for line in otoolOutput[1:] if ("Qt" in line
or "phonon" in line)
and not "@executable_path" in line]
frameworks = [lib[:lib.find(".framework")+len(".framework")] for lib in libs]
frameworks = [framework[framework.rfind('/')+1:] for framework in frameworks]
libs = [line.split()[0] for line in otoolOutput[1:] if ("Qt" in line or "phonon" in line) and "@executable_path" not in line]
frameworks = [lib[:lib.find(".framework") + len(".framework")] for lib in libs]
frameworks = [framework[framework.rfind('/') + 1:] for framework in frameworks]
return zip(frameworks, libs)


def changeDylPath(self, obj, framework, lib):
newlibname = framework + lib.split(framework)[1]
if self.bundle:
newlibname = "@executable_path/../Frameworks/%s" % newlibname
else:
newlibname = "@executable_path/Frameworks/%s" % newlibname

#print 'install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj)
# print 'install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj)
os.system('install_name_tool -change "%s" "%s" "%s"' % (lib, newlibname, obj))

if __name__ == "__main__":
Expand Down
14 changes: 8 additions & 6 deletions scripts/build/macosx_makebundle.py
Expand Up @@ -27,7 +27,7 @@
SOURCE_DIR = sys.argv[1]

if len(sys.argv) < 4:
BUNDLE_NAME= "Quassel Client"
BUNDLE_NAME = "Quassel Client"
EXE_NAME = "quasselclient"
else:
EXE_NAME = sys.argv[3]
Expand All @@ -38,33 +38,35 @@
CONTENTS_DIR = os.path.dirname(EXE_NAME) + "/"
CONTENTS_DIR += BUNDLE_NAME + ".app/Contents/"

BUNDLE_VERSION = commands.getoutput("git --git-dir="+SOURCE_DIR+"/.git/ describe")
BUNDLE_VERSION = commands.getoutput("git --git-dir=" + SOURCE_DIR + "/.git/ describe")
ICON_FILE = "pics/quassel.icns"


def createBundle():
try:
os.makedirs(CONTENTS_DIR + "MacOS")
os.makedirs(CONTENTS_DIR + "Resources")
except:
pass


def copyFiles(exeFile, iconFile):
os.system("cp %s %sMacOs/%s" % (exeFile, CONTENTS_DIR.replace(' ', '\ '), BUNDLE_NAME.replace(' ', '\ ')))
os.system("cp %s/%s %s/Resources" % (SOURCE_DIR, iconFile, CONTENTS_DIR.replace(' ', '\ ')))


def createPlist(bundleName, iconFile, bundleVersion):
templateFile = file(SOURCE_DIR + "/scripts/build/Info.plist", 'r')
template = templateFile.read()
templateFile.close()

plistFile = file(CONTENTS_DIR + "Info.plist", 'w')
plistFile.write(template % {"BUNDLE_NAME" : bundleName,
"ICON_FILE" : iconFile[iconFile.rfind("/")+1:],
"BUNDLE_VERSION" : bundleVersion})
plistFile.write(template % {"BUNDLE_NAME": bundleName,
"ICON_FILE": iconFile[iconFile.rfind("/") + 1:],
"BUNDLE_VERSION": bundleVersion})
plistFile.close()

if __name__ == "__main__":
createBundle()
createPlist(BUNDLE_NAME, ICON_FILE, BUNDLE_VERSION)
copyFiles(EXE_NAME, ICON_FILE)
pass

0 comments on commit 6c1008c

Please sign in to comment.