コード例 #1
0
def _sane_env(poetry, build_dir, io, clean=False):
    "Yield a sane virtual environment in build_dir."
    manager = EnvManager(poetry)
    if os.path.isdir(build_dir):
        env = VirtualEnv(build_dir)
        if clean or (not env.is_sane()):
            io.write_line(f"removing env {build_dir}")
            manager.remove_venv(build_dir)
    if not os.path.isdir(build_dir):
        io.write_line(f"building env {build_dir}")
        manager.build_venv(build_dir, executable=None)
    return VirtualEnv(build_dir)
コード例 #2
0
    def handle(self) -> None:
        from poetry.utils.env import EnvManager

        pythons = self.argument("python")
        all = self.option("all")
        if not (pythons or all):
            self.line("No virtualenv provided.")

        manager = EnvManager(self.poetry)
        # TODO: refactor env.py to allow removal with one loop
        for python in pythons:
            venv = manager.remove(python)
            self.line(f"Deleted virtualenv: <comment>{venv.path}</comment>")
        if all:
            for venv in manager.list():
                manager.remove_venv(venv.path)
                self.line(
                    f"Deleted virtualenv: <comment>{venv.path}</comment>")