Skip to content

Commit 093bd23

Browse files
committed
cli: Add --ignore-plugin-setups option
This option lets you prevent Python configuration files from being loaded from CLOE_PLUGIN_PATH.
1 parent 68bccdc commit 093bd23

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

cli/cloe_launch/commands/_options.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ def extract_target_args(xargs) -> List[str]:
8080
should_append = True
8181
return results
8282

83+
def ignore_plugin_setups():
84+
"""Click option --ignore-plugin-setups.
85+
86+
Python files co-located in the CLOE_PLUGIN_PATH are loaded by cloe-launch.
87+
However, CLOE_PLUGIN_PATH is currently approximated through identifying
88+
directories in LD_LIBRARY_PATH that contain a cloe directory.
89+
This approximation doesn't always work out, for example if LD_LIBRARY_PATH
90+
contains relative paths, such as ".".
91+
92+
In this case you may want to disable plugin-setup loading, espcially if
93+
you know that you don't need it.
94+
"""
95+
return click.option(
96+
"--ignore-plugin-setups",
97+
is_flag=True,
98+
help="Ignore python plugin setup configuration files."
99+
)
83100

84101
def preserve_env():
85102
"""Click option --preserve-env."""

cli/cloe_launch/commands/exec.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@cli_command("exec")
3636
@_options.preserve_env()
3737
@_options.override_env()
38+
@_options.ignore_plugin_setups()
3839
@_options.cache()
3940
@click.option(
4041
"-d",
@@ -49,6 +50,7 @@ def cli_exec(
4950
conf: Configuration,
5051
preserve_env: bool,
5152
override_env: List[str],
53+
ignore_plugin_setups: bool,
5254
cache: bool,
5355
debug: bool,
5456
conanfile: str,
@@ -71,6 +73,7 @@ def cli_exec(
7173
engine = Engine(conf, conanfile=conanfile)
7274
engine.conan_args = _options.extract_conan_args(args)
7375
engine.preserve_env = preserve_env
76+
engine.load_plugin_setups = not ignore_plugin_setups
7477

7578
# Run cloe-engine and pass on returncode:
7679
# If cloe-engine is killed/aborted, subprocess will return 250.

cli/cloe_launch/commands/shell.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
@cli_command("shell")
3636
@_options.preserve_env()
3737
@_options.override_env()
38+
@_options.ignore_plugin_setups()
3839
@_options.cache()
3940
@_options.conanfile()
4041
@_options.args()
@@ -43,6 +44,7 @@ def cli_shell(
4344
conf: Configuration,
4445
preserve_env: bool,
4546
override_env: List[str],
47+
ignore_plugin_setups: bool,
4648
cache: bool,
4749
conanfile: str,
4850
args: List[str],
@@ -68,6 +70,7 @@ def cli_shell(
6870
engine = Engine(conf, conanfile=conanfile)
6971
engine.preserve_env = preserve_env
7072
engine.conan_args = _options.extract_conan_args(args)
73+
engine.load_plugin_setups = not ignore_plugin_setups
7174

7275
# Replace process with shell.
7376
engine.shell(_options.extract_target_args(args), use_cache=cache)

cli/cloe_launch/exec.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def __init__(self, conf: Configuration, conanfile: Optional[str] = None):
110110
self.preserve_env: bool = False
111111
self.conan_args: List[str] = []
112112
self.capture_output = True
113+
self.load_plugin_setups = True
113114

114115
logging.info(f"Profile name: {self.profile}")
115116
logging.info("Configuration:")
@@ -523,7 +524,9 @@ def shell(
523524
env = self._prepare_runtime_env(use_cache)
524525
self._write_runtime_env(env)
525526

526-
plugin_setups = self._prepare_plugin_setups(env)
527+
plugin_setups = []
528+
if self.load_plugin_setups:
529+
plugin_setups = self._prepare_plugin_setups(env)
527530
shell = os.getenv("SHELL", "/bin/bash")
528531

529532
# Print the final environment, if desired
@@ -694,9 +697,11 @@ def exec(
694697
plugin setup and teardown."""
695698
env = self._prepare_runtime_env(use_cache)
696699
self._write_runtime_env(env)
697-
plugin_setups = self._prepare_plugin_setups(env)
698700

699701
# Initialize plugin setups:
702+
plugin_setups = []
703+
if self.load_plugin_setups:
704+
plugin_setups = self._prepare_plugin_setups(env)
700705
for plugin in plugin_setups:
701706
logging.debug(
702707
f"Initializing plugin setup for {plugin.name} at {plugin.plugin}"

0 commit comments

Comments
 (0)