-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hooks: add hook for googleapiclient.model #82
Conversation
Reproduces the error from pyinstaller/pyinstaller#5332 and pyinstaller#14, which is caused by missing metadata.
The googleapiclient.model module uses pkg_resources and its get_distribution() function to query the version of "google-api-python-client" package, therefore we need to collect its metadata. Fixes pyinstaller/pyinstaller#5332. Fixes pyinstaller#14.
Hi, I really appreciate this hook. I'm using Blogger API on my project but raises error due to NoneType when calling build(). from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
CLIENT_CONFIG = {
"installed": {
"client_id": "xxxxx-xxxxxxx.apps.googleusercontent.com",
"project_id": "xxxxxxxxx",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "xxxxxxxxxxxxxxxx",
"redirect_uris": [
"urn:ietf:wg:oauth:2.0:oob",
"http://localhost"
]
}
}
SCOPES = ['https://www.googleapis.com/auth/blogger']
try:
flow = InstalledAppFlow.from_client_config(CLIENT_CONFIG, SCOPES) # this opens default browser to login
auth_credentials = flow.run_local_server(success_message="You can close this window now") # if not accepted... what happens?
blogger_service = build('blogger', 'v3', credentials=auth_credentials) # here happens the error
except Exception as e:
print("Some error happened")
print(e) # prints -> name: blogger version: v3 Looking at the code for the # adding googleapiclient.discovery correctly
from PyInstaller.utils.hooks import collect_data_files
datas += collect_data_files('googleapiclient.discovery', include_py_files=True, excludes=['*.txt', '**/__pycache__']) Now it works as I needed for blogger, I guess it'll work for other services than Blogger. Hope this helps. |
Eek @Legorooj we haven't done a release since Novermber... |
Actually I manually released it a day or 2 ago. Forgot to tag it in the repo though 😬. |
The
googleapiclient.model
module usespkg_resources
and itsget_distribution()
function to query the version ofgoogle-api-python-client
package, therefore we need to collect its metadata.Fixes pyinstaller/pyinstaller#5332.
Fixes #14.