pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.29k stars 628 forks source link

Default package resolver is not working for Azure Packages #21165

Open rhuanbarreto opened 2 months ago

rhuanbarreto commented 2 months ago

Describe the bug

I'm on v2.21.0 of pants but I'm still getting warnings despite the references in https://github.com/pantsbuild/pants/blob/release_2.21.0/src/python/pants/backend/python/dependency_inference/default_module_mapping.py:

16:15:14.27 [WARN] Pants cannot infer owners for the following imports in the target [redacted]:

  * azure.storage.filedatalake.DataLakeServiceClient (line: 2)

If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies for common problems.
16:15:14.27 [WARN] Pants cannot infer owners for the following imports in the target [redacted]:

  * azure.storage.filedatalake.ContentSettings (line: 3)

If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see https://www.pantsbuild.org/2.21/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies for common problems.
16:15:14.27 [WARN] Pants cannot infer owners for the following imports in the target [redacted]:

  * azure.storage.filedatalake.PathProperties (line: 4)

Pants version Which version of Pants are you using?

2.21.0

OS

MacOS

krishnan-chandra commented 2 months ago

I think you may have to add this specific mapping into your BUILD file because the package name is azure-storage-file-datalake and the import is azure.storage.filedatalake (note the lack of separator between file and datalake).

It doesn't follow the same pattern as the other Azure imports, so you'll probably need something like this in your BUILD file:

module_mapping={
        "azure-storage-file-datalake": ["azure.storage.filedatalake"],
        ...
}
rhuanbarreto commented 2 months ago

@krishnan-chandra what about this one?

07:31:14.16 [WARN] Pants cannot infer owners for the following imports in the target [redacted]:

  * azure.core.exceptions.ResourceNotFoundError (line: 6)
krishnan-chandra commented 2 months ago

I'm guessing that azure-core is a transitive dependency in your repo from one or more of the other Azure packages - the package documentation on PyPI suggests that you usually don't need to include azure-core directly. I think you'll need to add a similar module mapping for the package that you do import, or add azure-core as an explicit dependency.