average-australia-85137
02/24/2021, 5:32 PMsrc/BUILD
python_library(
name='server'
)
src/app.py
which imports fraud.api
I would assume that fraud/api.py would be included in the ./pants dependencies --transitive src:server
output? However it is not present - (it is very possible that I am misunderstanding the dependency inference capabilities)hundreds-father-404
02/24/2021, 5:34 PMfraud.api
. See the warning at https://www.pantsbuild.org/docs/targets#sources
2) Source roots are not configured properly
What is the file corresponding to fraud.api
?average-australia-85137
02/24/2021, 5:41 PMsrc
From that link i saw the ./pants list fraud/api.py
command which seemed helpful!
Scrubbed PYTHONPATH=/home/nate/wave/remit-srv/src: from the environment.
12:38:51.90 [INFO] initializing pantsd...
12:38:52.29 [INFO] pantsd initialized.
12:38:52.95 [ERROR] Exception caught: (pants.engine.internals.scheduler.ExecutionError)
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 276, in run
engine_result = self._run_v2(goals)
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 190, in _run_v2
return self._maybe_run_v2_body(goals, poll=False)
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/bin/local_pants_runner.py", line 207, in _maybe_run_v2_body
return self.graph_session.run_goal_rules(
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/init/engine_initializer.py", line 131, in run_goal_rules
exit_code = self.scheduler_session.run_goal_rule(
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 563, in run_goal_rule
self._raise_on_error([t for _, t in throws])
File "/home/nate/.cache/pants/setup/bootstrap-Linux-x86_64/2.2.0_py38/lib/python3.8/site-packages/pants/engine/internals/scheduler.py", line 531, in _raise_on_error
raise ExecutionError(
Exception message: 1 Exception encountered:
ResolveError: No owning targets could be found for the file `src/fraud/api.py`.
Please check that there is a BUILD file in `src/fraud` with a target whose `sources` field includes `src/fraud/api.py`. See <https://www.pantsbuild.org/v2.2/docs/targets> for more information on target definitions.
If you would like to ignore un-owned files, please pass `--owners-not-found-behavior=ignore`.
hundreds-father-404
02/24/2021, 5:43 PMdo I need to add a BUILD file to all directories in my project for dependency inference to work?More or less, yeah. And Pants 2.3 can automate this for you. Change
pants_version = "2.3.0rc0"
, then run ./pants tailor
(Lmk if Pants fails to run, there's an issue with running in certain linux environments we're trying to isolate)witty-crayon-22786
02/24/2021, 5:44 PM./pants tailor
, as it will update your BUILD files. but yea, itβs for precisely this case.average-australia-85137
02/24/2021, 5:50 PMwitty-crayon-22786
02/24/2021, 5:52 PMhappy-kitchen-89482
02/24/2021, 6:04 PMtailor
in a clean commit as it doesn't have a dry run mode (yet?) and will actively modify your build files. Although it only appends, never modifies existing targets.average-australia-85137
02/24/2021, 6:05 PMAs explained in Targets and BUILD files, you can use fewer BUILD files, such as one BUILD file per subproject; but we find that one BUILD file per directory is a good default.Which sounds like it dependency inference will still work even if you only have one BUILD file per larger unit of code (e.g. the top level package)
hundreds-father-404
02/24/2021, 6:08 PMWhich sounds like it dependency inference will still work even if you only have one BUILD file per larger unit of code (e.g. the top level package)Yeah, it should, but only if you set
sources=["**/*.py"]
for example so that every Python file has a single owning target
Although now that ./pants tailor
exists and it's less expensive to create one BUILD file per directory, we want to encourage even more using that style, whereas before we were more that either approach is valid. That section should probably be rewritten nowaverage-australia-85137
02/24/2021, 6:10 PMhundreds-father-404
02/24/2021, 6:10 PMaverage-australia-85137
02/24/2021, 6:12 PMhundreds-father-404
02/24/2021, 7:18 PMaverage-australia-85137
02/24/2021, 7:30 PM