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

pantsbuild: Generate PEX lockfile for st2 #5830

Merged
merged 3 commits into from
Dec 2, 2022
Merged

Conversation

cognifloyd
Copy link
Member

@cognifloyd cognifloyd commented Dec 2, 2022

Background

This is another part of introducing pants, as discussed in various TSC meetings.

Related PRs can be found in:

Overview of this PR

This introduces a lockfile for our 3rd party dependencies (based on dependencies/constraints from #5789 and python constraints from #5795).

To create this lockfile, we need to register a "resolve" (called "st2") in pants, which represents the wold of direct and transitive dependencies required by our code. We also register the dependency constraints file added in #5789.

Finally, we create the lockfile by running ./pants generate-lockfiles --resolve=st2.

Note that the lockfile has 4840 lines. Beyond that this PR only:

  • adds 11 lines to pants.toml
  • updates 1 line in CHANGELOG.rst

Relevant Pants documentation

Resolves and Lockfiles

Pants has multiple resolves, where a resolve represents the world of dependencies for some tool or code. Each resolve can have a lockfile associated with it. All tools (like black, flake8, etc) have lockfiles by default, but first-party code only gets a lockfile if we enable resolves and add a lockfile for it. So, we:

  • enable resolves by setting [python].enable_resolves = true in pants.toml;
  • name the resolve for our code "st2" instead of defaulting to the name "python-default" by setting [python].default-resolve = "st2";
  • register the st2 resolve's lockfile by setting [python.resolves].st2 = "lockfiles/st2.lock"; and
  • register the st2 resolve's constraints file by setting [python.resolves_to_constraints_file].st2 = "lockfiles/st2-constraints.txt".

Finally, generate the lockfile with ./pants generate-lockfiles --resolve=st2.

We can also regenerate all lockfiles (st2 and tools) with ./pants generate-lockfiles.

@cognifloyd cognifloyd added this to the pants milestone Dec 2, 2022
@cognifloyd cognifloyd self-assigned this Dec 2, 2022
@pull-request-size pull-request-size bot added the size/XXL PR that changes 1000+ lines. You should absolutely split your PR into several. label Dec 2, 2022
@@ -85,12 +85,23 @@ root_patterns = [
]

[python]
# resolver_version is always "pip-2020-resolver". legacy is not supported.
Copy link
Member Author

Choose a reason for hiding this comment

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

Our current infra relies on the legacy resolver and old versions of pip. Old versions of pants also supported the older pip + legacy resolver, but the version we're using now does not.

So, I left this comment here for future reference and to call out this departure from how we used to do things.

Copy link
Contributor

@nzlosh nzlosh left a comment

Choose a reason for hiding this comment

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

Nice job!

Copy link

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Woohoo!

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

@cognifloyd cognifloyd merged commit 284ccd4 into master Dec 2, 2022
@cognifloyd cognifloyd deleted the pants-st2-lockfile branch December 2, 2022 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external dependency pantsbuild python3 size/XXL PR that changes 1000+ lines. You should absolutely split your PR into several.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants