forked from python-poetry/poetry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow removing multiple (and all) environments at once (python-poetry…
…#3212) Co-authored-by: Arun Babu Neelicattu <arun.neelicattu@gmail.com> Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
- Loading branch information
Showing
3 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
from cleo.helpers import argument | ||
from cleo.helpers import option | ||
|
||
from ..command import Command | ||
|
||
|
||
class EnvRemoveCommand(Command): | ||
|
||
name = "env remove" | ||
description = "Removes a specific virtualenv associated with the project." | ||
description = "Remove virtual environments associated with the project." | ||
|
||
arguments = [ | ||
argument("python", "The python executable to remove the virtualenv for.") | ||
argument( | ||
"python", | ||
"The python executables associated with, or names of the virtual environments which are to " | ||
"be removed.", | ||
optional=True, | ||
multiple=True, | ||
) | ||
] | ||
options = [ | ||
option( | ||
"all", | ||
description="Remove all managed virtual environments associated with the " | ||
"project.", | ||
), | ||
] | ||
|
||
def handle(self) -> None: | ||
from poetry.utils.env import EnvManager | ||
|
||
manager = EnvManager(self.poetry) | ||
venv = manager.remove(self.argument("python")) | ||
pythons = self.argument("python") | ||
all = self.option("all") | ||
if not (pythons or all): | ||
self.line("No virtualenv provided.") | ||
|
||
self.line("Deleted virtualenv: <comment>{}</comment>".format(venv.path)) | ||
manager = EnvManager(self.poetry) | ||
# TODO: refactor env.py to allow removal with one loop | ||
for python in pythons: | ||
venv = manager.remove(python) | ||
self.line("Deleted virtualenv: <comment>{}</comment>".format(venv.path)) | ||
if all: | ||
for venv in manager.list(): | ||
manager.remove_venv(venv.path) | ||
self.line("Deleted virtualenv: <comment>{}</comment>".format(venv.path)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters