Exemplo n.º 1
0
 def __init__(self, message, no_version_found=False):
     extra = (
         "{}: Your dependencies could not be resolved. You likely have a "
         "mismatch in your sub-dependencies.\n  "
         "First try clearing your dependency cache with {}, then try the original command again.\n "
         "Alternatively, you can use {} to bypass this mechanism, then run "
         "{} to inspect the situation.\n  "
         "Hint: try {} if it is a pre-release dependency."
         "".format(
             crayons.red("Warning", bold=True),
             crayons.yellow("$ pipenv lock --clear"),
             crayons.yellow("$ pipenv install --skip-lock"),
             crayons.yellow("$ pipenv graph"),
             crayons.yellow("$ pipenv lock --pre"),
         ),
     )
     if "no version found at all" in message:
         no_version_found = True
     message = crayons.yellow(f"{message}")
     if no_version_found:
         message = "{}\n{}".format(
             message,
             crayons.cyan(
                 "Please check your version specifier and version number. "
                 "See PEP440 for more information."
             )
         )
     PipenvException.__init__(self, message, extra=extra)
Exemplo n.º 2
0
 def __init__(self, package, command, return_values, return_code, **kwargs):
     extra = [
         "{} {}".format(crayons.cyan("Attempted to run command: "),
                        crayons.yellow(f"$ {command!r}", bold=True))
     ]
     extra.extend([
         crayons.cyan(line.strip()) for line in return_values.splitlines()
     ])
     if isinstance(package, (tuple, list, set)):
         package = " ".join(package)
     message = "{!s} {!s}...".format(
         crayons.normal("Failed to uninstall package(s)"),
         crayons.yellow(f"{package}!s", bold=True))
     self.exit_code = return_code
     PipenvException.__init__(self, message=message, extra=extra)
     self.extra = extra
Exemplo n.º 3
0
 def __init__(self, package, **kwargs):
     package_message = ""
     if package is not None:
         package_message = "Couldn't install package: {}\n".format(
             crayons.normal(f"{package!s}", bold=True))
     message = "{} {}".format(
         f"{package_message}",
         crayons.yellow("Package installation failed..."))
     extra = kwargs.pop("extra", [])
     PipenvException.__init__(self, message=message, extra=extra, **kwargs)
Exemplo n.º 4
0
def verify(state):
    """Verify the hash in Pipfile.lock is up-to-date."""
    if not state.project.pipfile_exists:
        echo("No Pipfile present at project home.", err=True)
        sys.exit(1)
    if state.project.get_lockfile_hash(
    ) != state.project.calculate_pipfile_hash():
        echo(
            "Pipfile.lock is out-of-date. Run {} to update.".format(
                crayons.yellow("$ pipenv lock", bold=True)),
            err=True,
        )
        sys.exit(1)
    echo(crayons.green("Pipfile.lock is up-to-date."))
    sys.exit(0)
Exemplo n.º 5
0
def update(ctx, state, bare=False, dry_run=None, outdated=False, **kwargs):
    """Runs lock, then sync."""
    from ..core import do_lock, do_outdated, do_sync, ensure_project

    ensure_project(
        state.project,
        three=state.three,
        python=state.python,
        pypi_mirror=state.pypi_mirror,
        warn=(not state.quiet),
        site_packages=state.site_packages,
        clear=state.clear,
    )
    if not outdated:
        outdated = bool(dry_run)
    if outdated:
        do_outdated(
            state.project,
            clear=state.clear,
            pre=state.installstate.pre,
            pypi_mirror=state.pypi_mirror,
        )
    packages = [p for p in state.installstate.packages if p]
    editable = [p for p in state.installstate.editables if p]
    if not packages:
        echo("{} {} {} {}{}".format(
            crayons.normal("Running", bold=True),
            crayons.yellow("$ pipenv lock", bold=True),
            crayons.normal("then", bold=True),
            crayons.yellow("$ pipenv sync", bold=True),
            crayons.normal(".", bold=True),
        ))
    else:
        for package in packages + editable:
            if package not in state.project.all_packages:
                echo(
                    "{}: {} was not found in your Pipfile! Aborting."
                    "".format(
                        crayons.red("Warning", bold=True),
                        crayons.green(package, bold=True),
                    ),
                    err=True,
                )
                ctx.abort()
    do_lock(
        state.project,
        ctx=ctx,
        clear=state.clear,
        pre=state.installstate.pre,
        keep_outdated=state.installstate.keep_outdated,
        pypi_mirror=state.pypi_mirror,
        write=not state.quiet,
    )
    do_sync(
        state.project,
        dev=state.installstate.dev,
        three=state.three,
        python=state.python,
        bare=bare,
        dont_upgrade=not state.installstate.keep_outdated,
        user=False,
        clear=state.clear,
        unused=False,
        sequential=state.installstate.sequential,
        pypi_mirror=state.pypi_mirror,
    )