Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable pantsbuild language backends #5725

Merged
merged 1 commit into from
Sep 12, 2022
Merged

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Sep 7, 2022

Background

This is part 3 of introducing pants, as discussed in the TSC Meetings on 12 July 2022, 02 Aug 2022 and 06 Sept 2022. Pants has fine-grained per-file caching of results for lint, fmt (like black), test, etc. It also has lockfiles that work well for monorepos that have multiple python packages. With these lockfiles CI should not break when any of our dependencies or our transitive dependencies release new versions, because CI will continue to use the locked version until we explicitly relock with updates.

To keep PRs as manageable/reviewable as possible, introducing pants will take a series of PRs. I do not know yet how many PRs; I will break this up into logical steps with these goals:

  • introduce pants to the st2 repo, and
  • teach some (but not all) TSC members about pants step-by-step.

Other pants PRs include:

Overview of this PR

This PR enables language-specific backends for pants. This is step 3 in the initial configuration document:
https://www.pantsbuild.org/docs/initial-configuration#enable-backends

The next PR will do step 5 in the initial configuration document. It will be generated by running some automation to add metadata across the repo. This PR is the manual configuration that has to be done before we can run that process.

This does not add any lint/fmt/etc backends, just the language-specific ones. That will happen in PRs after we have added metadata across the repo.

pants.toml config file

Pants configuration lives in a file called pants.toml in the root of the repo.

https://www.pantsbuild.org/docs/initial-configuration#create-pantstoml

Many important things get configured in the pants.toml config file, but this PR only configures [GLOBAL].backend_packages.

[GLOBAL].backend_packages

The pants docs describe [GLOBLA].backend_packages as follows:

Most Pants functionality is opt-in by adding the relevant backend to the [GLOBAL].backend_packages option in pants.toml.

https://www.pantsbuild.org/docs/enabling-backends

So, this is how we opt-in to different funcitonality. In this PR, we tell pants that we have python and shell files in this repo. We'll add other backends (like flake8 and black) in follow-up PRs.

Things you can do with pantsbuild

This PR does not wire up any lockfiles, formatters, linters, etc, yet.

After this PR pants has more targets (metadata about a subset of code) and goals (like count-loc or roots from the previous PRs).

To explore this, use the ./pants help system (which is extremely helpful!).

Before this PR

asciicast

After this PR

asciicast

@cognifloyd cognifloyd added this to the 3.8.0 milestone Sep 7, 2022
@cognifloyd cognifloyd self-assigned this Sep 7, 2022
@pull-request-size pull-request-size bot added the size/S PR that changes 10-29 lines. Very easy to review. label Sep 7, 2022
Base automatically changed from pants-source_roots to master September 8, 2022 10:30
@pull-request-size pull-request-size bot added size/M PR that changes 30-99 lines. Good size to review. and removed size/S PR that changes 10-29 lines. Very easy to review. labels Sep 8, 2022
@pull-request-size pull-request-size bot added size/S PR that changes 10-29 lines. Very easy to review. and removed size/M PR that changes 30-99 lines. Good size to review. labels Sep 8, 2022
@cognifloyd cognifloyd marked this pull request as ready for review September 8, 2022 12:52
pants.toml Outdated
backend_packages = [
# python
"pants.backend.python",
"pants.backend.experimental.python",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see experimental.python in list of pants backends on here: https://www.pantsbuild.org/docs/enabling-backends, why is experimental.python needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I left a comment. This enables support for the python publish goal (./pants publish) and the twine subsystem. The publish goal uses twine to publish wheels to pypi.

relevant docs are not linked in the sidebar because they are in the experimental backend.
https://www.pantsbuild.org/docs/python-publish-goal
https://www.pantsbuild.org/docs/reference-twine

Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok apart from would like to see clarification on the experimental.python backend.

Copy link
Contributor

@amanda11 amanda11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thanks for update on twine

https://www.pantsbuild.org/docs/initial-configuration\#enable-backends

This does not add any lint/fmt/etc backends, just the language-specific ones.

The experimental.python backend is required for twine support.
Twine is used to publish wheels to pypi.
Copy link
Member

@rush-skills rush-skills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infrastructure: ci/cd maintenance pantsbuild size/S PR that changes 10-29 lines. Very easy to review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants