def __init__(self, path: Path, *, verbose: bool = False, python: str = DEFAULT_PYTHON) -> None: self.root = path self._python = python self.bin_path, self.python_path = get_venv_paths(self.root) self.pipx_metadata = PipxMetadata(venv_dir=path) self.verbose = verbose self.do_animation = not verbose try: self._existing = self.root.exists() and next(self.root.iterdir()) except StopIteration: self._existing = False if self._existing and self.uses_shared_libs and not shared_libs.is_valid: logging.warning( f"Shared libraries not found, but are required for package {self.root.name}. " "Attempting to install now.") shared_libs.create([]) if shared_libs.is_valid: logging.info("Successfully created shared libraries") else: raise PipxError( f"Error: pipx's shared venv is invalid and " "needs re-installation. To fix this, install or reinstall a " "package. For example,\n" f" pipx install {self.root.name} --force")
def __init__(self, path: Path, *, verbose: bool = False, python: str = DEFAULT_PYTHON) -> None: self.root = path self.python = python self.bin_path, self.python_path = get_venv_paths(self.root) self.pipx_metadata = PipxMetadata(venv_dir=path) self.verbose = verbose self.do_animation = not verbose try: self._existing = self.root.exists() and next(self.root.iterdir()) except StopIteration: self._existing = False if self._existing and self.uses_shared_libs: if shared_libs.is_valid: if shared_libs.needs_upgrade: shared_libs.upgrade(verbose=verbose) else: shared_libs.create(verbose) if not shared_libs.is_valid: raise PipxError( pipx_wrap(f""" Error: pipx's shared venv {shared_libs.root} is invalid and needs re-installation. To fix this, install or reinstall a package. For example: """) + f"\n pipx install {self.root.name} --force", wrap_message=False, )
def __init__(self): self.root = PIPX_SHARED_LIBS self.bin_path, self.python_path = get_venv_paths(self.root) # i.e. bin_path is ~/.local/pipx/shared/bin # i.e. python_path is ~/.local/pipx/shared/python self._site_packages = None self.has_been_updated_this_run = False
def __init__(self) -> None: self.root = constants.PIPX_SHARED_LIBS self.bin_path, self.python_path = get_venv_paths(self.root) self.pip_path = self.bin_path / ("pip" if not WINDOWS else "pip.exe") # i.e. bin_path is ~/.local/pipx/shared/bin # i.e. python_path is ~/.local/pipx/shared/python self._site_packages: Optional[Path] = None self.has_been_updated_this_run = False
def test_uninstall_with_missing_interpreter(pipx_temp_env, capsys): assert not run_pipx_cli(["install", "pycowsay"]) _, python_path = util.get_venv_paths(constants.PIPX_LOCAL_VENVS / "pycowsay") assert python_path.is_file() python_path.unlink() assert not python_path.is_file() assert not run_pipx_cli(["uninstall", "pycowsay"])
def test_missing_interpreter(pipx_temp_env, monkeypatch, capsys): assert not run_pipx_cli(["install", "pycowsay"]) _, python_path = util.get_venv_paths(constants.PIPX_LOCAL_VENVS / "pycowsay") assert (python_path).is_file() assert not run_pipx_cli(["list"]) captured = capsys.readouterr() assert "package pycowsay has invalid interpreter" not in captured.out python_path.unlink() assert not run_pipx_cli(["list"]) captured = capsys.readouterr() assert "package pycowsay has invalid interpreter" in captured.out
def remove_venv_interpreter(venv_name): _, venv_python_path = util.get_venv_paths(constants.PIPX_LOCAL_VENVS / venv_name) assert venv_python_path.is_file() venv_python_path.unlink() assert not venv_python_path.is_file()