def create_gdk_pixbuf_loaders_setup(self): modulespath = "" cachepath = "" if os.path.exists(os.path.join(self.project.get_prefix(), "lib", "gdk-pixbuf-2.0")): modulespath = self.project.get_bundle_path("Contents/Resources/lib/", "gdk-pixbuf-2.0", "${pkg:gdk-pixbuf-2.0:gdk_pixbuf_binary_version}", "loaders") cachepath = self.project.get_bundle_path("Contents/Resources/lib/", "gdk-pixbuf-2.0", "${pkg:gdk-pixbuf-2.0:gdk_pixbuf_binary_version}", "loaders.cache") elif os.path.exists(os.path.join(self.project.get_prefix(), "lib", "gdk-pixbuf-3.0")): modulespath = self.project.get_bundle_path("Contents/Resources/lib/", "gdk-pixbuf-3.0", "${pkg:gdk-pixbuf-3.0:gdk_pixbuf_binary_version}", "loaders") cachepath = self.project.get_bundle_path("Contents/Resources/lib/", "gdk-pixbuf-3.0", "${pkg:gdk-pixbuf-3.0:gdk_pixbuf_binary_version}", "loaders.cache") else: modulespath = self.project.get_bundle_path("Contents/Resources/lib/", self.project.get_gtk_dir(), "${pkg:" + self.meta.gtk + ":gtk_binary_version}", "loaders") cachepath = self.project.get_bundle_path("Contents/Resources/etc/", self.project.get_gtk_dir(), "gdk-pixbuf.loaders") modulespath = utils.evaluate_pkgconfig_variables (modulespath) cachepath = utils.evaluate_pkgconfig_variables (cachepath) cmd = "GDK_PIXBUF_MODULEDIR=" + modulespath + " gdk-pixbuf-query-loaders" f = os.popen(cmd) utils.makedirs(os.path.dirname(cachepath)) fout = open(cachepath, "w") prefix = "\"" + self.project.get_bundle_path("Contents/Resources") for line in f: line = line.strip() if line.startswith("#"): continue # Replace the hardcoded bundle path with @executable_path... if line.startswith(prefix): line = line[len(prefix):] line = "\"@executable_path/../Resources" + line fout.write(line) fout.write("\n") fout.close()
def evaluate_path(self, path, include_bundle=True): p = re.compile("^\${prefix}") path = p.sub(self.get_prefix(), path) p = re.compile("^\${prefix:(.*?)}") m = p.match(path) if m: path = p.sub(self.get_prefix(m.group(1)), path) p = re.compile("^\${project}") path = p.sub(self.project_dir, path) try: p = re.compile("\${name}") path = p.sub(self.name, path) except AttributeError: pass # can be used before name path is set if include_bundle: try: p = re.compile("^\${bundle}") path = p.sub(self.get_bundle_path(), path) except AttributeError: pass # can be used before bundle path is set path = utils.evaluate_environment_variables(path) path = utils.evaluate_pkgconfig_variables(path) return os.path.normpath(path)
def create_gdk_pixbuf_loaders_setup(self): modulespath = self.project.get_bundle_path("Contents/Resources/lib/gtk-2.0/" + "${pkg:gtk+-2.0:gtk_binary_version}/"+ "loaders") modulespath = utils.evaluate_pkgconfig_variables (modulespath) cmd = "GDK_PIXBUF_MODULEDIR=" + modulespath + " gdk-pixbuf-query-loaders" f = os.popen(cmd) path = self.project.get_bundle_path("Contents/Resources/etc/gtk-2.0") utils.makedirs(path) fout = open(os.path.join(path, "gdk-pixbuf.loaders"), "w") prefix = "\"" + self.project.get_bundle_path("Contents/Resources") for line in f: line = line.strip() if line.startswith("#"): continue # Replace the hardcoded bundle path with @executable_path... if line.startswith(prefix): line = line[len(prefix):] line = "\"@executable_path/../Resources" + line fout.write(line) fout.write("\n") fout.close()
def create_pango_setup(self): # Create a temporary pangorc file just for creating the # modules file with the right modules. modulespath = self.project.get_bundle_path( "Contents/Resources/lib/pango/" + "${pkg:pango:pango_module_version}/" + "modules" ) modulespath = utils.evaluate_pkgconfig_variables(modulespath) import tempfile fd, tmp_filename = tempfile.mkstemp() f = os.fdopen(fd, "w") f.write("[Pango]\n") f.write("ModulesPath=" + modulespath) f.write("\n") f.close() cmd = "PANGO_RC_FILE=" + tmp_filename + " pango-querymodules" f = os.popen(cmd) path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) fout = open(os.path.join(path, "pango.modules"), "w") prefix = self.project.get_bundle_path("Contents/Resources") for line in f: line = line.strip() if line.startswith("#"): continue # Replace the hardcoded bundle path with @executable_path... if line.startswith(prefix): line = line[len(prefix) :] line = "@executable_path/../Resources" + line fout.write(line) fout.write("\n") fout.close() os.unlink(tmp_filename) # Create the final pangorc file path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) f = open(os.path.join(path, "pangorc"), "w") f.write("[Pango]\n") f.write("ModuleFiles=./pango.modules\n") f.close()
def create_pango_setup(self): # Create a temporary pangorc file just for creating the # modules file with the right modules. modulespath = self.project.get_bundle_path("Contents/Resources/lib/pango/" + "${pkg:pango:pango_module_version}/"+ "modules") modulespath = utils.evaluate_pkgconfig_variables (modulespath) import tempfile fd, tmp_filename = tempfile.mkstemp() f = os.fdopen(fd, "w") f.write("[Pango]\n") f.write("ModulesPath=" + modulespath) f.write("\n") f.close() cmd = "PANGO_RC_FILE=" + tmp_filename + " pango-querymodules" f = os.popen(cmd) path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) fout = open(os.path.join(path, "pango.modules"), "w") prefix = self.project.get_bundle_path("Contents/Resources") for line in f: line = line.strip() if line.startswith("#"): continue # Replace the hardcoded bundle path with @executable_path... if line.startswith(prefix): line = line[len(prefix):] line = "@executable_path/../Resources" + line fout.write(line) fout.close() os.unlink(tmp_filename) # Create the final pangorc file path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) f = open(os.path.join(path, "pangorc"), "w") f.write("[Pango]\n") f.write("ModuleFiles=./pango.modules\n") f.close()
def create_pango_setup(self): # Create a temporary pangorc file just for creating the # modules file with the right modules. module_version = utils.evaluate_pkgconfig_variables("${pkg:pango:pango_module_version}") modulespath = self.project.get_bundle_path("Contents/Resources/lib/pango/" + module_version + "/modules/") from distutils.version import StrictVersion as V import tempfile fd, tmp_filename = tempfile.mkstemp() f = os.fdopen(fd, "w") f.write("[Pango]\n") f.write("ModulesPath=" + modulespath) f.write("\n") f.close() cmd = "PANGO_RC_FILE=" + tmp_filename + " pango-querymodules" f = os.popen(cmd) path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) fout = open(os.path.join(path, "pango.modules"), "w") if V(module_version) < V('1.8.0'): prefix_path = os.path.join("Contents", "Resources") else: prefix_path = os.path.join("Contents", "Resources", "lib", "pango", module_version, "modules/") prefix = self.project.get_bundle_path(prefix_path) for line in f: line = line.strip() if line.startswith("# ModulesPath"): continue # Replace the hardcoded bundle path with @executable_path... if line.startswith(prefix): line = line[len(prefix):] #Newer versions of pango have been modified to look in the right place #for modules (providing the PANGO_LIB_DIR is set to point to the #bundle_lib folder). if V(module_version) < V('1.8.0'): line = "@executable_path/../Resources" + line fout.write(line) fout.write("\n") fout.close() os.unlink(tmp_filename) # Create the final pangorc file path = self.project.get_bundle_path("Contents/Resources/etc/pango") utils.makedirs(path) f = open(os.path.join(path, "pangorc"), "w") f.write("[Pango]\n") #Pango 2.32 (corresponding to module_version 1.8.0) and later don't #interpret "./" to mean the same directory that the rc file is in, so #this doesn't work any more. However, pango does know to look in the #bundle directory (when given the right environment variable), so we #don't need this, either. if V(module_version) < V('1.8.0'): f.write("ModuleFiles=./pango.modules\n") f.close()