'Build command-line and Pulsar client for this job.'

def __prepare_job(self, job_wrapper, job_destination):

    command_line = None
    client = None
    remote_job_config = None
    compute_environment = None
    try:
        client = self.get_client_from_wrapper(job_wrapper)
        tool = job_wrapper.tool
        remote_job_config = client.setup(tool.id, tool.version)
        PulsarJobRunner.check_job_config(remote_job_config)
        rewrite_parameters = PulsarJobRunner.__rewrite_parameters(client)
        prepare_kwds = {}
        if rewrite_parameters:
            compute_environment = PulsarComputeEnvironment(client, job_wrapper, remote_job_config)
            prepare_kwds['compute_environment'] = compute_environment
        job_wrapper.prepare(**prepare_kwds)
        self.__prepare_input_files_locally(job_wrapper)
        remote_metadata = PulsarJobRunner.__remote_metadata(client)
        dependency_resolution = PulsarJobRunner.__dependency_resolution(client)
        metadata_kwds = self.__build_metadata_configuration(client, job_wrapper, remote_metadata, remote_job_config)
        remote_command_params = dict(working_directory=remote_job_config['metadata_directory'], metadata_kwds=metadata_kwds, dependency_resolution=dependency_resolution)
        remote_working_directory = remote_job_config['working_directory']
        remote_job_directory = os.path.abspath(os.path.join(remote_working_directory, os.path.pardir))
        remote_tool_directory = os.path.abspath(os.path.join(remote_job_directory, 'tool_files'))
        container = self._find_container(job_wrapper, compute_working_directory=remote_working_directory, compute_tool_directory=remote_tool_directory, compute_job_directory=remote_job_directory)
        job_wrapper.disable_commands_in_new_shell()
        metadata_directory = None
        if remote_metadata:
            metadata_directory = remote_job_config['metadata_directory']
        command_line = build_command(self, job_wrapper=job_wrapper, container=container, include_metadata=remote_metadata, metadata_directory=metadata_directory, create_tool_working_directory=False, include_work_dir_outputs=False, remote_command_params=remote_command_params)
    except UnsupportedPulsarException as e:
        job_wrapper.fail(e.message, exception=False)
        log.exception('failure    running    job    %d', job_wrapper.job_id)
    except Exception:
        job_wrapper.fail('failure    preparing    job', exception=True)
        log.exception('failure    running    job    %d', job_wrapper.job_id)
    if (not command_line):
        job_wrapper.finish('', '')
    return (command_line, client, remote_job_config, compute_environment)
