-
Notifications
You must be signed in to change notification settings - Fork 346
fix: add missing packaging dependency for feature requiring urllib3 #1732
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
Conversation
…brary-python into add-dependency
| "reauth": "pyu2f>=0.1.5", | ||
| "enterprise_cert": ["cryptography", "pyopenssl"], | ||
| "pyjwt": ["pyjwt>=2.0", "cryptography>=38.0.3"], | ||
| "urllib3": ["urllib3", "packaging"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does user know to install this extra?
Maybe update the error msg in the try catch and tell users about this extra.
Also move packaging into the try?
| from packaging import version # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
installing dependency like pip install google-auth[urllib3] should install all the dependencies defined for urlllib3. I was thinking about updating error message, however I saw similar error in other modules, but this is definitely confusing. let me update the message to include google-auth[urllib3] command to avoid user installing directly from pip.
google/auth/transport/urllib3.py
Outdated
| raise ImportError( | ||
| "The urllib3 library is not installed from please install the " | ||
| "urllib3 package to use the urllib3 transport." | ||
| "Error: Missing 'urllib3' dependency for 'google-auth'." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same error msg for packaging as well.
Does the caught_exc have the name of the missing library?
Resolves an
ImportError: No module named 'packaging'encountered when using functionality in the urllib3.py file.The code paths relying on
urllib3transport also have a runtime dependency on thepackaginglibrary. This dependency was introduced in PR #1390.However,
packagingwas not explicitly listed as a requirement for theurllib3insetup.py. This was masked during development becausenoxoften installspackagingtransitively. Users installing the library without havingnoxor its dependencies installed separately would face anImportErrorwhen theurllib3dependent code executes.This PR fixes the issue by explicitly adding
packagingalongsideurllib3in the extras group definition. This ensures that installing the optional feature via the extra correctly pulls in all its necessary runtime dependencies.