def build(self, client, pull=False, usecache=True):
print(colored('<STR_LIT>', '<STR_LIT>'),<EOL>colored(self.imagename, '<STR_LIT>', attrs=['<STR_LIT>']),<EOL>colored('<STR_LIT>', '<STR_LIT>'),<EOL>colored(self.sourcefile, '<STR_LIT>', attrs=['<STR_LIT>']))<EOL>if self.build_first and not self.build_first.built:<EOL><INDENT>self.build_external_dockerfile(client, self.build_first)<EOL><DEDENT>if self.bust_cache:<EOL><INDENT>usecache = False<EOL><DEDENT>if not usecache:<EOL><INDENT>cprint('<STR_LIT>',<EOL>'<STR_LIT>')<EOL><DEDENT>dockerfile = u'<STR_LIT:\n>'.join(self.dockerfile_lines)<EOL>kwargs = dict(tag=self.buildname,<EOL>pull=pull,<EOL>nocache=not usecache,<EOL>decode=True, rm=True,<EOL>buildargs=self.buildargs,<EOL>squash=self.squash)<EOL>if usecache:<EOL><INDENT>utils.set_build_cachefrom(self.cache_from, kwargs, client)<EOL><DEDENT>if self.build_dir is not None:<EOL><INDENT>tempdir = self.write_dockerfile(dockerfile)<EOL>context_path = os.path.abspath(os.path.expanduser(self.build_dir))<EOL>kwargs.update(fileobj=None,<EOL>dockerfile=os.path.join(DOCKER_TMPDIR, '<STR_LIT>'))<EOL>print(colored('<STR_LIT>', '<STR_LIT>'),<EOL>colored(os.path.relpath(context_path), '<STR_LIT>', attrs=['<STR_LIT>']))<EOL>if not self.custom_exclude:<EOL><INDENT>kwargs.update(path=context_path)<EOL><DEDENT>else:<EOL><INDENT>print(colored('<STR_LIT>', '<STR_LIT>'),<EOL>colored(os.path.relpath(self.ignoredefs_file),  '<STR_LIT>', attrs=['<STR_LIT>']))<EOL>context = docker.utils.tar(self.build_dir,<EOL>exclude=self.custom_exclude,<EOL>dockerfile=(os.path.join(DOCKER_TMPDIR, '<STR_LIT>'),<EOL>dockerfile),<EOL>gzip=False)<EOL>kwargs.update(fileobj=context,<EOL>custom_context=True)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if sys.version_info.major == <NUM_LIT:2>:<EOL><INDENT>fileobj = StringIO(dockerfile)<EOL><DEDENT>else:<EOL><INDENT>fileobj = BytesIO(dockerfile.encode('<STR_LIT:utf-8>'))<EOL><DEDENT>kwargs.update(fileobj=fileobj,<EOL>path=None,<EOL>dockerfile=None)<EOL>tempdir = None<EOL><DEDENT>stream = client.api.build(**kwargs)<EOL>try:<EOL><INDENT>utils.stream_docker_logs(stream, self.buildname)<EOL><DEDENT>except docker.errors.APIError as e:<EOL><INDENT>if self.squash and not client.version().get('<STR_LIT>', False):<EOL><INDENT>raise errors.ExperimentalDaemonRequiredError(<EOL>'<STR_LIT>' + str(e) +<EOL>'<STR_LIT>'<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>raise errors.BuildError(dockerfile, str(e), kwargs)<EOL><DEDENT><DEDENT>except ValueError as e:<EOL><INDENT>raise errors.BuildError(dockerfile, str(e), kwargs)<EOL><DEDENT>if self.squash and not self.bust_cache:<EOL><INDENT>self._resolve_squash_cache(client)<EOL><DEDENT>if tempdir is not None:<EOL><INDENT>os.unlink(os.path.join(tempdir, '<STR_LIT>'))<EOL>os.rmdir(tempdir)<EOL><DEDENT>
Drives an individual build step. Build steps are separated by build_directory.
If a build has zero one or less build_directories, it will be built in a single
step.

Args:
    client (docker.Client): docker client object that will build the image
    pull (bool): whether to pull dependent layers from remote repositories
    usecache (bool): whether to use cached layers or rebuild from scratch