Skip to content
Open
Show file tree
Hide file tree
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
24 changes: 20 additions & 4 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,23 @@ def test_system_venv(self, tools_config):
extra_pkgs = tools_config["environments"][test_target][
"extra_packages"
]
extra_pkgs = " ".join(extra_pkgs)
pkgs_str = ""
ws = ""
for pkg in extra_pkgs:
pkgs_str += (
f"{ws}'{pkg}'"
if set(pkg).intersection(set("><"))
else f"{ws}{pkg}"
)
ws = " "

expected = {
"load": [f"source {self.lib_dir}/{test_target}/bin/activate"],
"unload": ["deactivate"],
"setup": [
f"rm -rf {self.lib_dir}/{test_target}",
f"python3 -m venv {self.lib_dir}/{test_target} --system-site-packages",
f"pip install {extra_pkgs}",
f"pip install {pkgs_str}",
],
}

Expand Down Expand Up @@ -272,7 +280,15 @@ def test_conda_pkgs(self, tools_config):
extra_pkgs = tools_config["environments"][test_target][
"extra_packages"
]
extra_pkgs = " ".join(extra_pkgs)
pkgs_str = ""
ws = ""
for pkg in extra_pkgs:
pkgs_str += (
f"{ws}'{pkg}'"
if set(pkg).intersection(set("><"))
else f"{ws}{pkg}"
)
ws = " "
conda_cmd = tools_config["environments"][test_target]["conda_cmd"]

expected = {
Expand All @@ -284,7 +300,7 @@ def test_conda_pkgs(self, tools_config):
"unload": ["conda deactivate"],
"setup": [
f"rm -rf {self.lib_dir}/{test_target}",
f"{conda_cmd} create -p {self.lib_dir}/{test_target} {extra_pkgs}",
f"{conda_cmd} create -p {self.lib_dir}/{test_target} {pkgs_str}",
],
}

Expand Down
5 changes: 3 additions & 2 deletions wellies/tools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shlex
from os import path
from typing import Dict
from typing import List
Expand Down Expand Up @@ -354,7 +355,7 @@ def __init__(
]
if extra_packages:
setup.extend(load)
pkgs = " ".join(extra_packages)
pkgs = " ".join([shlex.quote(pkg) for pkg in extra_packages])
setup.append(f"pip install {pkgs}")
super().__init__(name, depends, load, unload, setup, options=options)

Expand Down Expand Up @@ -544,7 +545,7 @@ def __init__(
A dictionary of options for the tool, by default {}.
"""
env_root = path.join(lib_dir, name)
packages_str = " ".join(packages)
packages_str = " ".join([shlex.quote(pkg) for pkg in packages])
setup = pf.TemplateScript(
conda_create,
ENV_DIR=env_root,
Expand Down