Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions build-support/bin/generate_builtin_lockfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from pants.backend.python.subsystems.ipython import IPython
from pants.backend.python.subsystems.pytest import PyTest
from pants.backend.python.subsystems.python_tool_base import PythonToolRequirementsBase
from pants.backend.python.subsystems.setup import Resolver
from pants.backend.python.subsystems.setuptools import Setuptools
from pants.backend.python.subsystems.setuptools_scm import SetuptoolsSCM
from pants.backend.python.subsystems.twine import TwineSubsystem
Expand Down Expand Up @@ -188,6 +189,13 @@ def create_parser() -> argparse.ArgumentParser:
parser.add_argument(
"--all-jvm", action="store_true", help="Regenerate all builtin JVM tool lockfiles."
)
parser.add_argument(
"--resolver",
type=Resolver,
choices=list(Resolver),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it necessary to specify the choices when the type is an enum? I thought we handled that automatically?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think it is handled automatically for the vanilla argparse used in this script.

default=Resolver.pex,
help="The Python resolver (pex or uv) used to generate Python tool lockfiles.",
)
parser.add_argument(
"--dry-run", action="store_true", help="Show Pants commands that would be run."
)
Expand All @@ -210,7 +218,7 @@ def create_parser() -> argparse.ArgumentParser:


def generate_python_tool_lockfiles(
tools: Sequence[PythonTool], dry_run: bool, keep_sandboxes: KeepSandboxes
tools: Sequence[PythonTool], resolver: Resolver, dry_run: bool, keep_sandboxes: KeepSandboxes
) -> None:
def req_file(_tool: PythonTool) -> str:
return f"{_tool.name}-requirements.txt"
Expand Down Expand Up @@ -252,7 +260,7 @@ def req_file(_tool: PythonTool) -> str:
"--python-pip-version=latest",
f"--python-interpreter-constraints=['{default_python_interpreter_constraints}']",
"--python-enable-resolves",
"--python-resolver=uv",
f"--python-resolver={resolver.value}",
# Unset any existing resolve names in the Pants repo, and set to just our temporary ones.
f"--python-resolves={resolves}",
f"--python-resolves-to-interpreter-constraints={resolves_to_ics}",
Expand Down Expand Up @@ -388,7 +396,9 @@ def main() -> None:
"or via the --all-python/--all-jvm flags."
)
if python_tools:
generate_python_tool_lockfiles(python_tools, args.dry_run, args.keep_sandboxes)
generate_python_tool_lockfiles(
python_tools, args.resolver, args.dry_run, args.keep_sandboxes
)
if jvm_tools:
generate_jvm_tool_lockfiles(jvm_tools, args.dry_run, args.keep_sandboxes)

Expand Down
Loading