MCPcopy Create free account
hub / github.com/Drakkar-Software/OctoBot / install_deps

Function install_deps

pants-plugins/python_plugins/register.py:93–131  ·  view source on GitHub ↗

Install third-party Python dependencies into the local Python environment. Collects all python_requirements() targets from the build graph (which represent only external/third-party packages) and runs pip install against the current interpreter. First-party packages like octobot_commons

(
    console: Console,
    targets: AllTargets,
    subsystem: InstallDepsSubsystem,
)

Source from the content-addressed store, hash-verified

91
92@goal_rule
93async def install_deps(
94 console: Console,
95 targets: AllTargets,
96 subsystem: InstallDepsSubsystem,
97) -> InstallDeps:
98 """Install third-party Python dependencies into the local Python environment.
99
100 Collects all python_requirements() targets from the build graph (which represent
101 only external/third-party packages) and runs pip install against the current
102 interpreter. First-party packages like octobot_commons or octobot_trading are
103 never installed because they are python_sources() targets, not requirements targets.
104
105 Usage:
106 pants install-deps :: # install from all requirements.txt files
107 pants install-deps --full :: # also include full_requirements.txt files
108 pants install-deps packages/commons:: # install deps for a specific package only
109 """
110 include_full = subsystem.full
111 requirements: set[str] = set()
112 for target in targets:
113 if not target.has_field(PythonRequirementsField):
114 continue
115 if not include_full and target.address.target_name == "full_reqs":
116 continue
117 for req in target[PythonRequirementsField].value:
118 requirements.add(str(req))
119
120 if not requirements:
121 console.print_stdout("No third-party requirements found.")
122 return InstallDeps(exit_code=0)
123
124 python = _shell_python()
125 sorted_reqs = sorted(requirements)
126 console.print_stdout(f"Installing {len(sorted_reqs)} packages into {python}...")
127 result = subprocess.run(
128 [python, "-m", "pip", "install", *sorted_reqs],
129 check=False,
130 )
131 return InstallDeps(exit_code=result.returncode)
132
133
134def rules():

Callers

nothing calls this directly

Calls 4

InstallDepsClass · 0.85
_shell_pythonFunction · 0.85
addMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected