<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def install_package(self, path, recursive=False, prefix=None):
 # type: (str, bool, str) -> tuple """ Installs all the modules found in the given package :param path: Path of the package (folder) :param recursive: If True, install the sub-packages too :param prefix: (**internal**) Prefix for all found modules :return: A 2-tuple, with the list of installed bundles and the list of failed modules names :raise ValueError: Invalid path """

        if not path:
            raise ValueError("Empty path")
        elif not is_string(path):
            raise ValueError("Path must be a string")

        # Use an absolute path
        path = os.path.abspath(path)
        if not os.path.exists(path):
            raise ValueError("Nonexistent path: {0}".format(path))

        # Create a simple visitor
        def visitor(fullname, is_package, module_path):
            # pylint: disable=W0613
            """
            Package visitor: accepts everything in recursive mode,
            else avoids packages
            """
            return recursive or not is_package

        # Set up the prefix if needed
        if prefix is None:
            prefix = os.path.basename(path)

        bundles = set()  # type: Set[Bundle]
        failed = set()  # type: Set[str]

        with self.__bundles_lock:
            try:
                # Install the package first, resolved from the parent directory
                bundles.add(self.install_bundle(prefix, os.path.dirname(path)))

                # Visit the package
                visited, sub_failed = self.install_visiting(
                    path, visitor, prefix
                )

                # Update the sets
                bundles.update(visited)
                failed.update(sub_failed)
            except BundleException as ex:
                # Error loading the module
                _logger.warning("Error loading package %s: %s", prefix, ex)
                failed.add(prefix)

        return bundles, failed