https://pantsbuild.org/ logo
#general
Title
# general
g

gentle-gigabyte-52115

02/21/2023, 11:08 AM
Question: should I be able to use visibility rules to create two projects like this with the same import path (both being app)? https://github.com/JoostvDoorn/pants-test-visibility-rule I tried this, but it seems to not work.
pants test ::
Gives an error:
Copy code
12:03:57.81 [WARN] The target project1/app/a_test.py:test imports `app.app.test_open_file`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['project1/app/app.py', 'project2/app/app.py'].
h

happy-kitchen-89482

02/21/2023, 12:49 PM
The visibility rules won't affect the deps that are inferred. Those rules are applied later to validate the dependencies after inference. However in Pants 2.16 this ambiguity will be resolved by source root, so project1/app/a_test.py will depend on project1/app/app.py because they are in the same source root, and not on project2/app/app.py, because (I assume) it is in a separate source root?
👍 1
g

gentle-gigabyte-52115

02/21/2023, 12:58 PM
In this example I do use source root with marker files and 2.16.0.dev7. Is this part of a later dev release? I saw before it was discussed here https://github.com/pantsbuild/pants/discussions/17389#discussioncomment-4039646, but I now see it was decided to not support use case 2.
I see I can do
ambiguity_resolution = "by_source_root"
under
[python-infer]
Thanks that works for me!
h

happy-kitchen-89482

02/21/2023, 1:31 PM
Ah, yes, this has to be turned on, sorry, forgot to mention that
4 Views