def _spec_from_modpath(modpath, path=None, context=None):
assert modpath<EOL>location = None<EOL>if context is not None:<EOL><INDENT>try:<EOL><INDENT>found_spec = spec.find_spec(modpath, [context])<EOL>location = found_spec.location<EOL><DEDENT>except ImportError:<EOL><INDENT>found_spec = spec.find_spec(modpath, path)<EOL>location = found_spec.location<EOL><DEDENT><DEDENT>else:<EOL><INDENT>found_spec = spec.find_spec(modpath, path)<EOL><DEDENT>if found_spec.type == spec.ModuleType.PY_COMPILED:<EOL><INDENT>try:<EOL><INDENT>location = get_source_file(found_spec.location)<EOL>return found_spec._replace(<EOL>location=location, type=spec.ModuleType.PY_SOURCE<EOL>)<EOL><DEDENT>except NoSourceFile:<EOL><INDENT>return found_spec._replace(location=location)<EOL><DEDENT><DEDENT>elif found_spec.type == spec.ModuleType.C_BUILTIN:<EOL><INDENT>return found_spec._replace(location=None)<EOL><DEDENT>elif found_spec.type == spec.ModuleType.PKG_DIRECTORY:<EOL><INDENT>location = _has_init(found_spec.location)<EOL>return found_spec._replace(location=location, type=spec.ModuleType.PY_SOURCE)<EOL><DEDENT>return found_spec<EOL>
given a mod path (i.e. split module / package name), return the
    corresponding spec

    this function is used internally, see `file_from_modpath`'s
    documentation for more information