def create_bundle(self, tmp=None): ''' Creates the Application bundle structure Contents/MacOS/MainExectuable -> Contents/Home/bin/main-executable Contents/Info.plist ''' tmp = tmp or tempfile.mkdtemp() contents = os.path.join(tmp, 'Contents') macos = os.path.join(contents, 'MacOS') resources = os.path.join(contents, 'Resources') for p in [contents, macos, resources]: if not os.path.exists(p): os.makedirs(p) # Create Contents/Info.plist # Use the template if provided in the package plist_tpl = None if os.path.exists(self.package.resources_info_plist): plist_tpl = open(self.package.resources_info_plist).read() framework_plist = ApplicationPlist( self.package.app_name, self.package.org, self.package.version, self.package.shortdesc, self.package.config.min_osx_sdk_version, os.path.basename(self.package.resources_icon_icns), plist_tpl) framework_plist.save(os.path.join(contents, 'Info.plist')) # Copy app icon to Resources shutil.copy(self.package.resources_icon_icns, resources) for f in self.package.osx_resources: f = self.package.relative_path(f) shutil.copy(f, resources) # Link or create a wrapper for the executables in Contents/MacOS for name, path, use_wrapper, wrapper in self.package.get_commands(): filename = os.path.join(macos, name) if use_wrapper: wrapper = self.package.get_wrapper(path, wrapper) if not wrapper: continue with open(filename, 'w') as f: f.write(wrapper) shell.call('chmod +x "%s"' % filename) else: # FIXME: We need to copy the binary instead of linking, because # beeing a different path, @executable_path will be different # and it we will need to set a different relative path with # install_name_tool shutil.copy(os.path.join(contents, 'Home', path), filename) return tmp
def testApplicationPackageType(self): self.info_plist = ApplicationPlist('test', 'test.org', '1.0', 'Test package') result = self.info_plist._get_properties_string() expected = self.PROPS_TPL % {'ptype': 'APPL', 'icon': ''} self.assertEquals(result, expected)