I'm having the hardest time getting google.auth.c...
# general
p
I'm having the hardest time getting google.auth.credentials|default|.. to be infered. Is there a way to force this? I have added it as an explicit dependency to the python_sources 🤔
1
Perhaps module_mapping
b
yeah,
module_mapping
(or
modules
on the low-level
python_requirement
target) is the right way to tell pants' dep inference when PyPI names differ to the module names used in code
👍 1
p
So in the world where.. google.cloud.exceptions Is apart of google.api_core.exceptions ... how do you handle that?
I did this.. but it feels wrong
Copy code
python_requirements(
    name="reqs",
    source="<http://requirements.in|requirements.in>",
    module_mapping={
      "google-auth": ["google.auth"],
      "google-api-core": ["google.cloud"]
    }
)
Copy code
from google.api_core.exceptions import NotFound, Conflict
The pypi package states
Copy code
This library is not meant to stand-alone. Instead it defines common helpers used by all Google API clients. For more information, see the documentation.
https://pypi.org/project/google-api-core/
b
I don't know the details of the GCP modules to know the right way to break them up. AFAIK, a single package can map to multiple, e..g
"google-api-core": ["google.cloud.exceptions", "google.api_core"]
, but I don't see
google.cloud.exceptions
in your code example so 🤷‍♂️
p
Ah I see..
google.cloud.exceptiosn maps to google-api-core
So like this..
Copy code
python_requirements(
    name="reqs",
    source="<http://requirements.in|requirements.in>",
    module_mapping={
      "google-auth": ["google.auth"],
      "google-api-core": ["google.cloud.exceptions"],
      "matplotlib": ["matplotlib", "pylab"]
    }
)
For matplotlib.. if I just has pyplot, it failed to find matplotlib.
Thank you @broad-processor-92400
👍 1