pantsbuild / example-python

An example repo to demonstrate Python support in Pants
Apache License 2.0
102 stars 77 forks source link

experimental: plugins: extended inferred dependencies from a plugin #121

Open AlexTereshenkov opened 1 year ago

AlexTereshenkov commented 1 year ago

DO NOT MERGE

Trying to find out if it's possible to extend the inferred dependencies from a plugin if a file doesn't exist, but should still be discovered to let Pants "think" this exists and can be imported.

$ ./pants dependencies helloworld/greet::                       
21:37:39.04 [INFO] Initializing scheduler...
21:37:39.17 [INFO] Scheduler initialized.
21:37:39.23 [WARN] InferSpecialDependenciesRequest(field_set=SpecialDependenciesInferenceFieldSet(address=Address(helloworld/greet:lib), sources=<class 'pants.backend.python.target_types.PythonSourcesGeneratingSourcesField'>(alias='sources', address=helloworld/greet:lib, value=('*.py', '*.pyi', '!test_*.py', '!*_test.py', '!tests.py', '!conftest.py', '!test_*.pyi', '!*_test.pyi', '!tests.pyi'), default=('*.py', '*.pyi', '!test_*.py', '!*_test.py', '!tests.py', '!conftest.py', '!test_*.pyi', '!*_test.pyi', '!tests.pyi'))))
21:37:39.25 [WARN] Owners([Address(helloworld/translator:lib)])
21:37:40.15 [ERROR] 1 Exception encountered:

  UnownedDependencyError: Pants cannot infer owners for the following imports in the target helloworld/greet/greeting.py:lib:

  * helloworld.translator.foobar.baz (line: 13)

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/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies for common problems.