Hi, I'm using pants in a Python project, that uses...
# general
g
Hi, I'm using pants in a Python project, that uses two resolves and one CLI entry-point. But pants produces a warning. In
BUILD
I declare:
Copy code
_resolves = ("default", "special")
__defaults__(all=dict(resolve=parametrize(*_resolves)))
And the
entry_points
looks like this:
Copy code
entry_points={
    "console_scripts": { "my-cmd": "my-pkg.my-cmd:main" },
}
I want this entry point to be installed no matter what lockfile is used. The entry point shouldn't care about the lockfile and just point to
my-pkg.my-cmd:main
. However, pants gives me this warning:
Copy code
[WARN] The python_distribution target packages/my-pkg:my-pkg has the field
`entry_points={'console_scripts': {'my-cmd': 'my-pkg.my-cmd:main'}}`,
which maps to the Python module `my-pkg.my-cmd`,
but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use:
['packages/my-pkg/my-cmd.py@resolve=default',
 'packages/my-pkg/my-cmd.py@resolve=special'].

Please explicitly include the dependency you want in the `dependencies` field of packages/my-pkg:my-pkg, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.

Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/2.20/docs/using-pants/troubleshooting-common-issues#import-errors-and-missing-dependencies>.
Do you have any advice how to resolve the warning? Because when the package is installed, the entry point is installed as intended. Thank you!
g
You must choose single resolve for a given target. Pants can't handle more than one.
d
I think this recommendation could help you (but you won't be able to use the
__defaults__
exactly the way you are: https://pantsbuild.slack.com/archives/C046T6T9U/p1734029106164119?thread_ts=1734025088.027889&amp;cid=C046T6T9U