def BuildWithPyInstaller(self): """Use pyinstaller to build a client package.""" self.CleanDirectory( config.CONFIG.Get("PyInstaller.distpath", context=self.context)) logging.info("Copying pyinstaller support files") self.spec_file = os.path.join(self.build_dir, "grr.spec") with open(self.spec_file, "wb") as fd: fd.write( config.CONFIG.Get("PyInstaller.spec", context=self.context)) with open(os.path.join(self.build_dir, "version.txt"), "wb") as fd: fd.write( config.CONFIG.Get("PyInstaller.version", context=self.context)) with open(os.path.join(self.build_dir, "grr.ico"), "wb") as fd: fd.write( config.CONFIG.Get("PyInstaller.icon", context=self.context)) # We expect the onedir output at this location. self.output_dir = os.path.join( config.CONFIG.Get("PyInstaller.distpath", context=self.context), "grr-client") # Pyinstaller doesn't handle unicode strings. args = [ "--distpath", str(config.CONFIG.Get("PyInstaller.distpath", context=self.context)), "--workpath", str( config.CONFIG.Get("PyInstaller.workpath_dir", context=self.context)), str(self.spec_file) ] logging.info("Running pyinstaller: %s", args) PyInstallerMain.run(pyi_args=[utils.SmartStr(x) for x in args]) # Clear out some crud that pyinstaller includes. for path in ["tcl", "tk", "pytz"]: dir_path = os.path.join(self.output_dir, path) try: shutil.rmtree(dir_path) os.mkdir(dir_path) # Create an empty file so the directories get put in the installers. with open(os.path.join(dir_path, path), "wb"): pass except OSError: pass version_ini = version.VersionPath() shutil.copy(version_ini, os.path.join(self.output_dir, "version.ini")) with open(os.path.join(self.output_dir, "build.yaml"), "wb") as fd: self.WriteBuildYaml(fd)
def BuildWithPyInstaller(context=None): """Use pyinstaller to build a client package.""" if context is None: raise ValueError("context has to be specified") CleanDirectory(config.CONFIG.Get("PyInstaller.distpath", context=context)) logging.info("Copying pyinstaller support files") build_dir = config.CONFIG.Get("PyInstaller.build_dir", context=context) spec_file = os.path.join(build_dir, "grr.spec") with io.open(spec_file, "w") as fd: fd.write(config.CONFIG.Get("PyInstaller.spec", context=context)) with io.open(os.path.join(build_dir, "version.txt"), "w") as fd: fd.write(config.CONFIG.Get("PyInstaller.version", context=context)) shutil.copy( src=config.CONFIG.Get("PyInstaller.icon_path", context=context), dst=os.path.join(build_dir, "grr.ico")) # We expect the onedir (a one-folder bundle containing an executable) output # at this location. output_dir = os.path.join( config.CONFIG.Get("PyInstaller.distpath", context=context), "grr-client") args = [ "--distpath", config.CONFIG.Get("PyInstaller.distpath", context=context), "--workpath", config.CONFIG.Get("PyInstaller.workpath_dir", context=context), spec_file, ] logging.info("Running pyinstaller: %s", args) PyInstallerMain.run(pyi_args=args) # Clear out some crud that pyinstaller includes. for path in ["tcl", "tk", "pytz"]: dir_path = os.path.join(output_dir, path) try: shutil.rmtree(dir_path) except OSError: logging.error("Unable to remove directory: %s", dir_path) try: os.mkdir(dir_path) except OSError: logging.error("Unable to create directory: %s", dir_path) file_path = os.path.join(dir_path, path) try: # Create an empty file so the directories get put in the installers. with io.open(file_path, "wb"): pass except IOError: logging.error("Unable to create file: %s", file_path) version_ini = config.CONFIG.Get( "ClientBuilder.version_ini_path", default=version.VersionPath()) shutil.copy(version_ini, os.path.join(output_dir, "version.ini")) build_yaml_path = os.path.join(output_dir, "build.yaml") with io.open(build_yaml_path, mode="w", encoding="utf-8") as fd: WriteBuildYaml(fd, context=context) return output_dir
def BuildWithPyInstaller(self): """Use pyinstaller to build a client package.""" self.CleanDirectory( config.CONFIG.Get("PyInstaller.distpath", context=self.context)) logging.info("Copying pyinstaller support files") self.spec_file = os.path.join(self.build_dir, "grr.spec") with open(self.spec_file, "wb") as fd: fd.write( config.CONFIG.Get("PyInstaller.spec", context=self.context)) with open(os.path.join(self.build_dir, "version.txt"), "wb") as fd: fd.write( config.CONFIG.Get("PyInstaller.version", context=self.context)) shutil.copy(src=config.CONFIG.Get("PyInstaller.icon_path", context=self.context), dst=os.path.join(self.build_dir, u"grr.ico")) # We expect the onedir output at this location. self.output_dir = os.path.join( config.CONFIG.Get("PyInstaller.distpath", context=self.context), "grr-client") args = [ "--distpath", config.CONFIG.Get("PyInstaller.distpath", context=self.context), "--workpath", config.CONFIG.Get("PyInstaller.workpath_dir", context=self.context), self.spec_file, ] logging.info("Running pyinstaller: %s", args) PyInstallerMain.run(pyi_args=args) # Clear out some crud that pyinstaller includes. for path in ["tcl", "tk", "pytz"]: dir_path = os.path.join(self.output_dir, path) try: shutil.rmtree(dir_path) except OSError: logging.error("Unable to remove directory: %s", dir_path) try: os.mkdir(dir_path) except OSError: logging.error("Unable to create directory: %s", dir_path) file_path = os.path.join(dir_path, path) try: # Create an empty file so the directories get put in the installers. with open(file_path, "wb"): pass except IOError: logging.error("Unable to create file: %s", file_path) version_ini = version.VersionPath() shutil.copy(version_ini, os.path.join(self.output_dir, "version.ini")) with open(os.path.join(self.output_dir, "build.yaml"), "wb") as fd: self.WriteBuildYaml(fd)