0

I am getting started with Bazel, and I am looking towards a Python monorepo. I would like to have, say, a subtree with "projects", that is something that can be deployed or run, and a subtree with libraries. In that libraries subtree I would like to have subject-related subtrees, for example:

my_workspace
  +- libraries
  |  +- django
  |  |  +- view  # stuff related to views
  |  |  +- model # stuff related to models
  |  +- database
  |     +- something_related_to_databases
  +- projects
    ...

But reading the documentation, I can't quite figure out what the best way to do this is. Should I have separate workspaces for libraries and projects? Should I have just BUILD.bazel files there? If so, what should be in those build files? Or should I have a build file in my root (my_workspace) declaring each of my libraries and projects? Is this monorepo structure correct or wrong? Where can I find out more?

UPD: The thing that was not obvious to me was that you can have empty build files in your nested folders.

Ibolit
  • 9,218
  • 7
  • 52
  • 96
  • 1
    Bazel doesn't really prescribe a particular directory structure, instead, it gives you the tools to create whatever structure you want. – silvergasp Aug 20 '22 at 20:19
  • 1
    A good place to look for examples for python+Bazel monorepos would be in the google github organisation. e.g. google/pigweed or google/jax – silvergasp Aug 20 '22 at 20:24
  • @silvergasp Thank you for the relies, I will have a look. I am worried I may fall into using antipatterns at the very beginning of my journey into Bazel and may lead a lot of people into that trap, so I'm trying to look for some instructions on good and bad practices. – Ibolit Aug 21 '22 at 10:08

0 Answers0