example-python icon indicating copy to clipboard operation
example-python copied to clipboard

Enhanced example

Open thomassajot opened this issue 3 years ago • 9 comments

Hi, It would be great for new user to have an idea of how a "monorepo" is setup using Pants. In addition, it would be good to have an example where the tests are not alongside the source code, as this is a common practice in usual python code bases.

thomassajot avatar Feb 14 '22 10:02 thomassajot

It would also include the example 3rdparty directory and other structures mentioned in the documentation.

thomassajot avatar Feb 14 '22 13:02 thomassajot

Thanks for the suggestion! We went with the top-level structure here to show off how to use Pants in the simplest case. I agree it would be helpful to show the other layouts at https://www.pantsbuild.org/docs/source-roots#examples

At the same time, we want to keep the simple example as simple as we can: https://github.com/pantsbuild/example-python/pull/85

Any suggestions for how we could best demo two layouts without getting too confusing? I'm thinking we could have two top-level folders simple_layout, polyglot_layout. Nothing else in the top-level other than the README.md. Then, each of those two directories have their own pants.toml etc? That is, they are entirely self-contained.

Eric-Arellano avatar Feb 14 '22 15:02 Eric-Arellano

Either that or create multiple example-python repos. example-python-minimal, example-python-monorepo, example-python-polyglot, ...

thomassajot avatar Feb 15 '22 16:02 thomassajot

Or, multiple branches.. to keep things together... Could name the branches according to style.. or something along those lines, perhaps.

kaos avatar Feb 16 '22 16:02 kaos

Or, multiple branches.. to keep things together...

A challenge here is maintenance. For example, we have 2.9 vs 2.8 branches already. I wouldn't want to have 2.9-minimal, 2.9-polyglot, and then have to do a distinct PR for each.

I think my bias would be still keep a single repo, but have different layouts as distinct folders. That's easier for us to maintain than multiple repos, e.g. fewer PRs to update; and it's less fragmentation -> better discovery.

Eric-Arellano avatar Feb 22 '22 21:02 Eric-Arellano

This seems like a good way to go.

thomassajot avatar Feb 24 '22 08:02 thomassajot

@thomassajot any interest in getting this started? Per https://github.com/pantsbuild/example-python/pull/85, we'd want to keep the new polyglot setup pretty simple; could even use the same code as the current example.

Eric-Arellano avatar Feb 24 '22 08:02 Eric-Arellano

Do you have any new examples or good resources on understanding python sources vs distribution vs library? I think I’m missing something probably very obvious in these examples. Also for python sources what is the use of name=lib? Is this some convention or should the name change across different folders and python sources declarations ?

sluthra1 avatar Feb 13 '24 05:02 sluthra1

The best resources are the docs at pantsbuild.org - and you can ask questions on our Slack channel (linked from the docs).

benjyw avatar Feb 16 '24 00:02 benjyw