What is the link between source roots and BUILD fi...
# general
q
What is the link between source roots and BUILD files? Only directories that match a source root will be scanned for a BUILD file?
So this setup won't work properly?
Copy code
application/
  BUILD
  pyroject.toml
  app.py
library/
  BUILD
  pyproject.toml
  src/
    __init__.py
    module.py
For library, the BUILD needs to be at the same level of pyproject.toml. Therefore, it can't be at the same level as the actual source files.
f
unless I misunderstand your needs, you don’t have to put
BUILD
in the
src
directory — it can be where it is now.
https://github.com/pantsbuild/pants/issues/12195#issuecomment-859598247 may be useful, sorry if isn’t — I asked a question about the layout
❤️ 1
w
see https://www.pantsbuild.org/docs/source-roots for more information: but you can think of a source root as similar to a PYTHONPATH entry
it’s the portion of the filepath that is chopped off, while the rest of the path is used as the module name
but also, you can absolutely create more than one
BUILD
file: we recommend using the
./pants tailer
goal to maintain most of your
BUILD
files: https://www.pantsbuild.org/v2.6/docs/create-initial-build-files
q
So there is no link between source roots and BUILD files then?
w
no, there shouldn’t be. see the source_roots page linked above for more information on how to create source roots: via filename patterns, marker files, etc