def BuildWithPyInstaller(self):
    """Use pyinstaller to build a client package."""
    self.CleanDirectory(config_lib.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_lib.CONFIG.Get("PyInstaller.spec", context=self.context))

    with open(os.path.join(self.build_dir, "version.txt"), "wb") as fd:
      fd.write(config_lib.CONFIG.Get("PyInstaller.version",
                                     context=self.context))

    with open(os.path.join(self.build_dir, "grr.ico"), "wb") as fd:
      fd.write(config_lib.CONFIG.Get("PyInstaller.icon", context=self.context))

    # We expect the onedir output at this location.
    self.output_dir = os.path.join(
        config_lib.CONFIG.Get("PyInstaller.distpath", context=self.context),
        "grr-client")

    # Pyinstaller doesn't handle unicode strings.
    args = ["--distpath", str(config_lib.CONFIG.Get("PyInstaller.distpath",
                                                    context=self.context)),
            "--workpath", str(config_lib.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 __HOLE__:
        pass

    with open(os.path.join(self.output_dir, "build.yaml"), "w") as fd:
      fd.write("Client.build_environment: %s\n" %
               rdf_client.Uname.FromCurrentSystem().signature())
      fd.write("Client.build_time: '%s'\n" %
               str(rdfvalue.RDFDatetime().Now()))
dataset/ETHPy150Open google/grr/grr/lib/build.py/ClientBuilder.BuildWithPyInstaller