gentle-flower-25372
02/27/2024, 3:50 PMBUILD
file and it's still failing to find the dependency. For context:
[python-infer]
unowned_dependency_behavior = "error"
ambiguity_resolution = "by_source_root"
curved-television-6568
02/27/2024, 4:48 PM.gitignore
file too)
https://www.pantsbuild.org/2.19/reference/global-options#pants_ignore
https://www.pantsbuild.org/2.19/reference/global-options#pants_ignore_use_gitignoregentle-flower-25372
02/27/2024, 5:31 PMpants_ignore
.gentle-flower-25372
02/27/2024, 5:33 PM__defaults__
apply to macros in the BUILD file itself?
__defaults__(
all=dict(
resolve="my-resolve",
)
)
docker_image(
name="docker",
)
poetry_requirements(
name="poetry",
)
gentle-flower-25372
02/27/2024, 5:33 PMpoetry_requirements
inherit from those __defaults__
?gentle-flower-25372
02/27/2024, 5:43 PMpants dependents "apps/graph-relay:poetry#requests"
and that also didn't yield what I would expect.gentle-flower-25372
02/27/2024, 5:48 PMgentle-flower-25372
02/27/2024, 6:00 PMpants_ignore_use_gitignore = false
and the same behavior exists.curved-television-6568
02/27/2024, 6:50 PM__defaults__
apply to macros in the BUILD file itself?
I'm not really following what you mean here. But you can easily verify this by pants peek some/path:docker
etc to see what value the resolve
field got.
Having __defaults__
in the macro should work, but I wouldn't recommend it however, as it's effect is from the point it is declared and for all it's sub directories and can then be overridden as needed at a lower level. When placed in a macro, this mechanism is no longer in effect, as every BUILD file will have the same defaults declaration at all levels, you can no longer sensibly override it for a sub tree.
If you want defaults for the entire project, simply putting a __defaults__
in a BUILD
file in the project root will do.gentle-flower-25372
02/27/2024, 6:52 PMcurved-television-6568
02/27/2024, 6:53 PMI'm not sure which file in particular you're referring toYour source files. There was nothing in your question indicating it was about 3rd party dependencies. Given it's about 3rd party deps, my suggestions doesn't apply π We would be able to give better assistance if you show more of what you tried, the command invoked and any output/error given.
gentle-flower-25372
02/27/2024, 6:53 PM__defaults__
as a means of setting the resolver for that particular project within the monorepo.gentle-flower-25372
02/27/2024, 6:53 PMcurved-television-6568
02/27/2024, 6:53 PMgentle-flower-25372
02/27/2024, 6:54 PMgentle-flower-25372
02/27/2024, 6:54 PMcurved-television-6568
02/27/2024, 6:55 PMgentle-flower-25372
02/27/2024, 6:55 PMcurved-television-6568
02/27/2024, 6:56 PMcurved-television-6568
02/27/2024, 7:33 PMlogger
instance, so simply <http://logger.info|logger.info>(...)
should do π )
To try it out, clone the pantsbuild/pants repo then run pants as PANTS_SOURCE=path/to/pants-repo pants ...
it rebuilds as needed when you make changes in the pants repo.curved-television-6568
02/27/2024, 7:35 PM__defaults__
apply to macros in the BUILD file itself?
Ah, regarding this is terminology misunderstanding. We call them targets
not macros, as there is a thing called "pants prelude file" in which you can define functions, referred to as "macros". Hence my confusion.
edit: https://www.pantsbuild.org/2.19/docs/writing-plugins/macroscurved-television-6568
02/27/2024, 7:36 PMcareful-address-89803
02/28/2024, 7:01 PMgentle-flower-25372
03/21/2024, 6:39 PMgentle-flower-25372
03/21/2024, 6:40 PM{
"name": "requests",
"reference": {
"lineno": 4,
"weak": false
},
"resolved": {
"status": "ImportOwnerStatus.unowned",
"address": []
},
"possible_resolve": [
[
"apps/packages/company-commons:poetry#requests@resolve=company-devops",
"company-devops"
],
[
"utility/company-devops:poetry#requests",
"company-devops"
]
]
}
Even if I add an explicit dependency in python_sources dependencies, it still doesn't pickup the right requests.gentle-flower-25372
03/21/2024, 6:46 PMgentle-flower-25372
03/21/2024, 6:46 PMcurved-television-6568
03/21/2024, 8:31 PMcareful-address-89803
03/22/2024, 3:00 AMlist[tuple[Address, ResolveName]]
). If pants can't identify the owner, it will/should emit a warning about that and then return ImportOwnerStatus.unowned. You can/should be able to use explicitly provided dependencies to get a resolution
source referencecareful-address-89803
03/22/2024, 3:03 AMcurved-television-6568
03/22/2024, 7:34 AM08:31:14.58 [WARN] The target src/python/a/b.py imports `requests`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['3rdparty/python:default#requests', '3rdparty/python:test#requests'].
I just hit that, and will investigate it for my use case... (it's a single resolve, but I've split it onto two different requirements files and apparently it leaves duplicate targets for "requests" in that resolve.. although I've only listed in one of the files, and likely is a transient dep to some other req from the other file..)curved-television-6568
03/22/2024, 7:41 AMcurved-television-6568
03/22/2024, 7:45 AMcurved-television-6568
03/22/2024, 7:46 AMsource
field on my second python_requirements
target..)gentle-flower-25372
03/22/2024, 12:34 PM