(self, cmd, line)
| 107 | print("Note: you may need to restart the kernel to use updated packages.") |
| 108 | |
| 109 | def _run_command(self, cmd, line): |
| 110 | args = shlex.split(line) |
| 111 | command = args[0] if len(args) > 0 else "" |
| 112 | args = args[1:] if len(args) > 1 else [""] |
| 113 | |
| 114 | extra_args = [] |
| 115 | |
| 116 | # When the subprocess does not allow us to respond "yes" during the installation, |
| 117 | # we need to insert --yes in the argument list for some commands |
| 118 | stdin_disabled = getattr(self.shell, 'kernel', None) is not None |
| 119 | needs_yes = command in CONDA_COMMANDS_REQUIRING_YES |
| 120 | has_yes = set(args).intersection(CONDA_YES_FLAGS) |
| 121 | if stdin_disabled and needs_yes and not has_yes: |
| 122 | extra_args.append("--yes") |
| 123 | |
| 124 | # Add --prefix to point conda installation to the current environment |
| 125 | needs_prefix = command in CONDA_COMMANDS_REQUIRING_PREFIX |
| 126 | has_prefix = set(args).intersection(CONDA_ENV_FLAGS) |
| 127 | if needs_prefix and not has_prefix: |
| 128 | extra_args.extend(["--prefix", sys.prefix]) |
| 129 | |
| 130 | self.shell.system(" ".join([cmd, command] + extra_args + args)) |
| 131 | print("\nNote: you may need to restart the kernel to use updated packages.") |
| 132 | |
| 133 | @line_magic |
| 134 | @is_conda_environment |
no test coverage detected