Repository: iterative/dvc

Issue:
gdrive: raises unexpected error - name: drive  version: v2
# Bug Report

## Description

DVC native packages bundled with [`pyinstaller`](https://www.pyinstaller.org) don't include the [Google API Discovery](https://developers.google.com/discovery) cache directory containing the [`drive.v2.json`](https://github.com/googleapis/google-api-python-client/blob/6970659a84d0eec6ff72f59e906716036516922e/googleapiclient/discovery_cache/documents/drive.v2.json) file, which is essential for the Google Drive remote operations.

This issue could be seamlessly fixed with https://github.com/pyinstaller/pyinstaller-hooks-contrib/pull/97, but we might need to find an alternative until the changes on that pull request get released through a stable channel. I guess that we could temporarily add the patched [`hook-googleapiclient.model.py`](https://github.com/sirdeniel/pyinstaller-hooks-contrib/blob/1f33069caac35e984dd88ab506fca99ddca7b733/src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-googleapiclient.model.py) file as part of our [custom hooks directory](https://github.com/iterative/dvc/tree/f52763a0b3e854e813840bb449bc34cacfcd4c92/scripts/hooks).

### How to reproduce

1. Create an empty project:
    ```console
    $ mkdir test && cd test
    $ git init && dvc init
    Initialized empty Git repository in ./test/.git/
    Initialized DVC repository.
    ```

2. Add a dummy file:
    ```console
    $ touch file && dvc add file
    WARNING: 'file' is empty.
    ···
    ```

3. [Configure the remote](https://dvc.org/doc/user-guide/setup-google-drive-remote):
    ```console
    $ dvc remote add origin gdrive://root
    $ dvc remote modify origin gdrive_use_service_account true   
    $ dvc remote modify origin gdrive_service_account_json_file_path account.json
    ```

4.  Reproduce the issue:
    ```console
    $ dvc push --remote origin
    ERROR: unexpected error - name: drive  version: v2
    ```

_Note: these steps have been reproduced with the official [`dvc_2.0.5_amd64.deb`](https://github.com/iterative/dvc/releases/download/2.0.5/dvc_2.0.5_amd64.deb) build._

### Expected result

Ideally, `dvc pull` should be able to pull data from the Google Drive remote.

```console
$ dvc push --remote origin
···
```

### Environment information

**Output of `dvc doctor`**

```console
$ dvc doctor
DVC version: 2.0.5 (deb)
---------------------------------
Platform: Python 3.7.10 on Linux-5.4.0-1040-azure-x86_64-with-debian-bullseye-sid
Supports: All remotes
Cache types: <https://error.dvc.org/no-dvc-cache>
Caches: local
Remotes: None
Workspace directory: ext4 on /dev/root
Repo: dvc, git
```

**Additional Information**

This issue is specific to [`pyinstaller`](https://www.pyinstaller.org) builds, and has been succesfully reproduced with the binaries generated through the [`build_posix.sh`](https://github.com/iterative/dvc/blob/a72cea67f16225c8af5e89bfd6717685d5451de1/scripts/build_posix.sh) packaging script:

https://github.com/iterative/dvc/blob/8c1d46e502af8bd3ad69fdbb06b5048ba2bb5e30/scripts/build_posix.sh#L91-L95 

Our [`iterative/setup-dvc`](https://github.com/iterative/setup-dvc) GitHub Action also seems to be affected by this issue on every [environment](https://github.com/actions/virtual-environments#available-environments) but the Windows ones, which rely exclusively on PyPI packages.


Discussion:
I experienced the same issue with the recently release debian package https://github.com/iterative/dvc/releases/tag/2.0.5 
I (can't guarantee but I) assume it boils down to the package containing a faulty version of `google-api-python-client`.
The same issue occured with a pip install with a problematic version of the package 
https://stackoverflow.com/questions/66477468/data-version-control-with-google-drive-remote-googleapiclient-errors-unknownap

I uninstalled the debian package and pip installed the newest versions of `dvc` and `dvc[gdrive]` and it works fine

... sry just finished reading your entire bug report
you got it figured out already ^^

Resolving patch:
diff --git a/scripts/hooks/hook-googleapiclient.model.py b/scripts/hooks/hook-googleapiclient.model.py
new file mode 100644
--- /dev/null
+++ b/scripts/hooks/hook-googleapiclient.model.py
@@ -0,0 +1,8 @@
+"""Temporary fix for https://github.com/iterative/dvc/issues/5618."""
+from PyInstaller.utils.hooks import (  # pylint:disable=import-error
+    collect_data_files,
+    copy_metadata,
+)
+
+datas = collect_data_files("googleapiclient.discovery")
+datas += copy_metadata("google_api_python_client")


Test patch: