Skip to content

Commit

Permalink
constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Oct 30, 2024
1 parent 80e6025 commit 780b063
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 111 deletions.
14 changes: 10 additions & 4 deletions bbot/core/helpers/depsinstaller/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,16 @@ async def pip_install(self, packages, constraints=None):

command = [sys.executable, "-m", "pip", "install", "--upgrade"] + packages

if constraints:
constraints_tempfile = self.parent_helper.tempfile(constraints, pipe=False)
command.append("--constraint")
command.append(constraints_tempfile)
# if no custom constraints are provided, use the constraints of the currently installed version of bbot
if constraints is not None:
import pkg_resources

dist = pkg_resources.get_distribution("bbot")
constraints = [str(r) for r in dist.requires()]

constraints_tempfile = self.parent_helper.tempfile(constraints, pipe=False)
command.append("--constraint")
command.append(constraints_tempfile)

process = None
try:
Expand Down
9 changes: 8 additions & 1 deletion bbot/test/bbot_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,11 @@ def install_all_python_deps():
deps_pip = set()
for module in DEFAULT_PRESET.module_loader.preloaded().values():
deps_pip.update(set(module.get("deps", {}).get("pip", [])))
subprocess.run([sys.executable, "-m", "pip", "install"] + list(deps_pip))

import pkg_resources

dist = pkg_resources.get_distribution("bbot")
constraints = [str(r) for r in dist.requires()]
constraint_file = tempwordlist(constraints)

subprocess.run([sys.executable, "-m", "pip", "install", "--constraint", constraint_file] + list(deps_pip))
3 changes: 1 addition & 2 deletions bbot/test/test_step_1/test_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def test_preset_yaml(clean_default_config):
debug=False,
silent=True,
config={"preset_test_asdf": 1},
strict_scope=False,
)
preset1 = preset1.bake()
assert "evilcorp.com" in preset1.target
Expand Down Expand Up @@ -210,7 +209,7 @@ def test_preset_scope():
"evilcorp.org",
whitelist=["evilcorp.de"],
blacklist=["test.www.evilcorp.de"],
strict_scope=True,
config={"scope": {"strict": True}},
)

preset1.merge(preset3)
Expand Down
Loading

0 comments on commit 780b063

Please sign in to comment.