forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow python tools to be installed from a user resolve. (pantsbuild#1…
…8418) This is intended to eventually replace the "tool lockfile" functionality, so that we have just one uniform way of generating lockfiles.
- Loading branch information
Showing
7 changed files
with
147 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/python/pants/backend/python/subsystems/python_tool_base_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2023 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import annotations | ||
|
||
from pants.backend.python.subsystems.python_tool_base import PythonToolBase | ||
from pants.backend.python.util_rules.pex_requirements import PexRequirements, Resolve | ||
from pants.testutil.option_util import create_subsystem | ||
from pants.util.ordered_set import FrozenOrderedSet | ||
|
||
|
||
class _DummyTool(PythonToolBase): | ||
options_scope = "dummy" | ||
register_lockfile = True | ||
default_lockfile_resource = ("dummy", "dummy") | ||
default_lockfile_url = "dummy" | ||
|
||
|
||
def test_install_from_resolve_default() -> None: | ||
tool = create_subsystem( | ||
_DummyTool, | ||
lockfile="dummy.lock", | ||
install_from_resolve="dummy_resolve", | ||
requirements=["foo", "bar", "baz"], | ||
version="", | ||
extra_requirements=[], | ||
) | ||
pex_reqs = tool.pex_requirements() | ||
assert isinstance(pex_reqs, PexRequirements) | ||
assert pex_reqs.from_superset == Resolve("dummy_resolve") | ||
assert pex_reqs.req_strings == FrozenOrderedSet(["bar", "baz", "foo"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters