Ejemplo n.º 1
0
    def upgrade(self, pip_args: List[str], verbose: bool = False):
        # Don't try to upgrade multiple times per run
        if self.has_been_updated_this_run:
            logging.info(f"Already upgraded libraries in {self.root}")
            return
        logging.info(f"Upgrading shared libraries in {self.root}")

        ignored_args = ["--editable"]
        _pip_args = [arg for arg in pip_args if arg not in ignored_args]
        if not verbose:
            _pip_args.append("-q")
        try:
            with animate("upgrading shared libraries", not verbose):
                run_verify([
                    self.python_path,
                    "-m",
                    "pip",
                    "--disable-pip-version-check",
                    "install",
                    *_pip_args,
                    "--upgrade",
                    "pip",
                    "setuptools",
                    "wheel",
                ])
                self.has_been_updated_this_run = True
            self.pip_path.touch()

        except Exception:
            logging.error("Failed to upgrade shared libraries", exc_info=True)
Ejemplo n.º 2
0
 def create(self, pip_args: List[str], verbose: bool = False):
     if not self.is_valid:
         with animate("creating shared libraries", not verbose):
             run_verify(
                 [DEFAULT_PYTHON, "-m", "venv", "--clear", self.root])
         # ignore installed packages to ensure no unexpected patches from the OS vendor
         # are used
         self.upgrade(["--ignore-installed"] + pip_args, verbose)
Ejemplo n.º 3
0
Archivo: venv.py Proyecto: ranzj/pipx
    def create_venv(self, venv_args: List[str], pip_args: List[str]) -> None:
        with animate("creating virtual environment", self.do_animation):
            cmd = [self.python, "-m", "venv", "--without-pip"]
            run_verify(cmd + venv_args + [str(self.root)])
        shared_libs.create(self.verbose)
        pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH
        # write path pointing to the shared libs site-packages directory
        # example pipx_pth location:
        #   ~/.local/pipx/venvs/black/lib/python3.8/site-packages/pipx_shared.pth
        # example shared_libs.site_packages location:
        #   ~/.local/pipx/shared/lib/python3.6/site-packages
        #
        # https://docs.python.org/3/library/site.html
        # A path configuration file is a file whose name has the form 'name.pth'.
        # its contents are additional items (one per line) to be added to sys.path
        pipx_pth.write_text(f"{shared_libs.site_packages}\n", encoding="utf-8")

        self.pipx_metadata.venv_args = venv_args
        self.pipx_metadata.python_version = self.get_python_version()
Ejemplo n.º 4
0
Archivo: venv.py Proyecto: ranzj/pipx
 def _run_pip(self, cmd: List[str]) -> None:
     cmd = [str(self.python_path), "-m", "pip"] + cmd
     if not self.verbose:
         cmd.append("-q")
     run_verify(cmd)