def file_build(self, path, modname=None):
try:<EOL><INDENT>stream, encoding, data = open_source_file(path)<EOL><DEDENT>except IOError as exc:<EOL><INDENT>raise exceptions.AstroidBuildingError(<EOL>"<STR_LIT>",<EOL>modname=modname,<EOL>path=path,<EOL>error=exc,<EOL>) from exc<EOL><DEDENT>except (SyntaxError, LookupError) as exc:<EOL><INDENT>raise exceptions.AstroidSyntaxError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>modname=modname,<EOL>path=path,<EOL>error=exc,<EOL>) from exc<EOL><DEDENT>except UnicodeError as exc:  <EOL><INDENT>raise exceptions.AstroidBuildingError(<EOL>"<STR_LIT>", filename=path<EOL>) from exc<EOL><DEDENT>with stream:<EOL><INDENT>if modname is None:<EOL><INDENT>try:<EOL><INDENT>modname = "<STR_LIT:.>".join(modutils.modpath_from_file(path))<EOL><DEDENT>except ImportError:<EOL><INDENT>modname = os.path.splitext(os.path.basename(path))[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>module = self._data_build(data, modname, path)<EOL>return self._post_build(module, encoding)<EOL><DEDENT>
Build astroid from a source code file (i.e. from an ast)

        *path* is expected to be a python source file