code: def set_executable(self, filename, env_filename=None):
      
      self._ensure_unfrozen('Setting the executable')
      if self._pex_info.script:
        raise self.InvalidExecutableSpecification('Cannot set both entry point and script of PEX!')
      if env_filename is None:
        env_filename = os.path.basename(filename)
      if self._chroot.get("executable"):
        raise self.InvalidExecutableSpecification(
            "Setting executable on a PEXBuilder that already has one!")
      self._copy_or_link(filename, env_filename, "executable")
      entry_point = env_filename
      entry_point = entry_point.replace(os.path.sep, '.')
      self._pex_info.entry_point = entry_point.rpartition('.')[0]
docs: Set the executable for this environment.
  
      :param filename: The file that should be executed within the PEX environment when the PEX is
        invoked.
      :keyword env_filename: (optional) The name that the executable file should be stored as within
        the PEX.  By default this will be the base name of the given filename.
  
      The entry point of the PEX may also be specified via ``PEXBuilder.set_entry_point``.