How to use the pipenv.patched.crayons.blue function in pipenv

To help you get started, we’ve selected a few pipenv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pypa / pipenv / pipenv / operations / install.py View on Github external
converted = requirementslib.Requirement.from_line(package_name)
                except ValueError as e:
                    click.echo('{0}: {1}'.format(crayons.red('WARNING'), e))
                    requirements_directory.cleanup()
                    sys.exit(1)
                if converted.is_vcs and not converted.editable:
                    click.echo(
                        '{0}: You installed a VCS dependency in non-editable mode. '
                        'This will work fine, but sub-dependencies will not be resolved by {1}.'
                        '\n  To enable this sub-dependency functionality, specify that this dependency is editable.'
                        ''.format(
                            crayons.red('Warning', bold=True),
                            crayons.red('$ pipenv lock'),
                        )
                    )
            click.echo(crayons.blue(format_pip_output(c.out)))
            # Ensure that package was successfully installed.
            try:
                assert c.return_code == 0
            except AssertionError:
                click.echo(
                    '{0} An error occurred while installing {1}!'.format(
                        crayons.red('Error: ', bold=True),
                        crayons.green(package_name),
                    ),
                    err=True,
                )
                click.echo(crayons.blue(format_pip_error(c.err)), err=True)
                if 'setup.py egg_info' in c.err:
                    click.echo(
                        "This is likely caused by a bug in {0}. "
                        "Report this to its maintainers.".format(
github pypa / pipenv / pipenv / core.py View on Github external
index=index_url,
                        extra_indexes=extra_index_url,
                        pypi_mirror=pypi_mirror,
                    )
                    if not c.ok:
                        sp.write_err(
                            u"{0} An error occurred while installing {1}!".format(
                                crayons.red(u"Error: ", bold=True), crayons.green(pkg_line)
                            ),
                        )
                        sp.write_err(
                            vistir.compat.fs_str(u"Error text: {0}".format(c.out))
                        )
                        sp.write_err(crayons.blue(vistir.compat.fs_str(format_pip_error(c.err))))
                        if environments.is_verbose():
                            sp.write_err(crayons.blue(vistir.compat.fs_str(format_pip_output(c.out))))
                        if "setup.py egg_info" in c.err:
                            sp.write_err(vistir.compat.fs_str(
                                "This is likely caused by a bug in {0}. "
                                "Report this to its maintainers.".format(
                                    crayons.green(pkg_requirement.name)
                                )
                            ))
                        sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format("Installation Failed"))
                        sys.exit(1)
                except (ValueError, RuntimeError) as e:
                    sp.write_err(vistir.compat.fs_str(
                        "{0}: {1}".format(crayons.red("WARNING"), e),
                    ))
                    sp.red.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(
                        "Installation Failed",
                    ))
github pypa / pipenv / pipenv / operations / ensure.py View on Github external
ensure_virtualenv(
            three=three, python=python, site_packages=site_packages
        )
        if warn:
            # Warn users if they are using the wrong version of Python.
            if project.required_python_version:
                path_to_python = which('python') or which('py')
                if path_to_python and project.required_python_version not in (
                    get_python_executable_version(path_to_python) or ''
                ):
                    click.echo(
                        '{0}: Your Pipfile requires {1} {2}, '
                        'but you are using {3} ({4}).'.format(
                            crayons.red('Warning', bold=True),
                            crayons.normal('python_version', bold=True),
                            crayons.blue(project.required_python_version),
                            crayons.blue(get_python_executable_version(path_to_python)),
                            crayons.green(shorten_path(path_to_python)),
                        ),
                        err=True,
                    )
                    if not deploy:
                        click.echo(
                            '  {0} will surely fail.'
                            ''.format(crayons.red('$ pipenv check')),
                            err=True,
                        )
                    else:
                        click.echo(crayons.red('Deploy aborted.'), err=True)
                        sys.exit(1)
    # Ensure the Pipfile exists.
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system)
github pypa / pipenv / pipenv / operations / install.py View on Github external
)
            traceback = e
        except AssertionError as e:
            error = (
                u'Requirements file doesn\'t appear to exist. Please ensure the file exists in your '
                'project directory or you provided the correct path.'
            )
            traceback = e
        finally:
            # If requirements file was provided by remote url delete the temporary file
            if remote:
                os.close(fd)  # Close for windows to allow file cleanup.
                os.remove(project.path_to(temp_reqs))
            if error and traceback:
                click.echo(crayons.red(error))
                click.echo(crayons.blue(str(traceback)), err=True)
                requirements_directory.cleanup()
                sys.exit(1)
    if code:
        click.echo(
            crayons.normal(
                u'Discovering imports from local codebase...', bold=True
            )
        )
        for req in import_from_code(code):
            click.echo('  Found {0}!'.format(crayons.green(req)))
            project.add_package_to_pipfile(req)
    # Capture -e argument and assign it to following package_name.
    more_packages = list(more_packages)
    if package_name == '-e':
        if not more_packages:
            raise click.BadArgumentUsage('Please provide path to editable package')
github pypa / pipenv / pipenv / core.py View on Github external
)
            traceback = e
        except AssertionError as e:
            error = (
                u"Requirements file doesn't appear to exist. Please ensure the file exists in your "
                "project directory or you provided the correct path."
            )
            traceback = e
        finally:
            # If requirements file was provided by remote url delete the temporary file
            if remote:
                fd.close()  # Close for windows to allow file cleanup.
                os.remove(temp_reqs)
            if error and traceback:
                click.echo(crayons.red(error))
                click.echo(crayons.blue(str(traceback)), err=True)
                sys.exit(1)
    if code:
        click.echo(
            crayons.normal(fix_utf8("Discovering imports from local codebase…"), bold=True)
        )
        for req in import_from_code(code):
            click.echo("  Found {0}!".format(crayons.green(req)))
            project.add_package_to_pipfile(req)
    # Allow more than one package to be provided.
    package_args = [p for p in packages] + [
        "-e {0}".format(pkg) for pkg in editable_packages
    ]
    # Support for --selective-upgrade.
    # We should do this part first to make sure that we actually do selectively upgrade
    # the items specified
    if selective_upgrade:
github pypa / pipenv / pipenv / exceptions.py View on Github external
def __init__(self, option_name="system", message=None, ctx=None, **kwargs):
        extra = kwargs.pop("extra", [])
        extra += [
            "{0}: --system is intended to be used for Pipfile installation, "
            "not installation of specific packages. Aborting.".format(
                crayons.red("Warning", bold=True)
            ),
        ]
        if message is None:
            message = crayons.blue("See also: {0}".format(crayons.white("--deploy flag.")))
        super(SystemUsageError, self).__init__(option_name, message=message, ctx=ctx, extra=extra, **kwargs)
github pypa / pipenv / pipenv / core.py View on Github external
if site_packages:
        click.echo(
            crayons.normal(fix_utf8("Making site-packages available…"), bold=True), err=True
        )
        cmd.append("--system-site-packages")

    if pypi_mirror:
        pip_config = {"PIP_INDEX_URL": vistir.misc.fs_str(pypi_mirror)}
    else:
        pip_config = {}

    # Actually create the virtualenv.
    error = None
    with create_spinner(u"Creating virtual environment...") as sp:
        with interrupt_handled_subprocess(cmd, combine_stderr=False, env=pip_config) as c:
            click.echo(crayons.blue(u"{0}".format(c.out)), err=True)
            if c.returncode != 0:
                error = c.err if environments.is_verbose() else exceptions.prettify_exc(c.err)
                sp.fail(environments.PIPENV_SPINNER_FAIL_TEXT.format(u"Failed creating virtual environment"))
            else:
                sp.green.ok(environments.PIPENV_SPINNER_OK_TEXT.format(u"Successfully created virtual environment!"))
    if error is not None:
        raise exceptions.VirtualenvCreationException(
            extra=crayons.red("{0}".format(error))
        )

    # Associate project directory with the environment.
    # This mimics Pew's "setproject".
    project_file_name = os.path.join(project.virtualenv_location, ".project")
    with open(project_file_name, "w") as f:
        f.write(vistir.misc.fs_str(project.project_directory))
    from .environment import Environment
github pypa / pipenv / pipenv / operations / virtualenv.py View on Github external
def cleanup_virtualenv(bare=True):
    """Removes the virtualenv directory from the system."""
    if not bare:
        click.echo(crayons.red('Environment creation aborted.'))
    try:
        # Delete the virtualenv.
        shutil.rmtree(project.virtualenv_location)
    except OSError as e:
        click.echo(
            '{0} An error occurred while removing {1}!'.format(
                crayons.red('Error: ', bold=True),
                crayons.green(project.virtualenv_location),
            ),
            err=True,
        )
        click.echo(crayons.blue(e), err=True)
github pypa / pipenv / pipenv / exceptions.py View on Github external
def __init__(self, package, command, return_values, return_code, **kwargs):
        extra = [
            "{0} {1}".format(
                crayons.blue("Attempted to run command: "),
                crayons.yellow("$ {0!r}".format(command), bold=True)
            )
        ]
        extra.extend([crayons.blue(line.strip()) for line in return_values.splitlines()])
        if isinstance(package, (tuple, list, set)):
            package = " ".join(package)
        message = "{0!s} {1!s}...".format(
            crayons.normal("Failed to uninstall package(s)"),
            crayons.yellow("{0}!s".format(package), bold=True)
        )
        self.exit_code = return_code
        PipenvException.__init__(self, message=message, extra=extra)
        self.extra = extra
github pypa / pipenv / pipenv / core.py View on Github external
pypi_mirror=pypi_mirror,
        )
        if warn:
            # Warn users if they are using the wrong version of Python.
            if project.required_python_version:
                path_to_python = which("python") or which("py")
                if path_to_python and project.required_python_version not in (
                    python_version(path_to_python) or ""
                ):
                    click.echo(
                        "{0}: Your Pipfile requires {1} {2}, "
                        "but you are using {3} ({4}).".format(
                            crayons.red("Warning", bold=True),
                            crayons.normal("python_version", bold=True),
                            crayons.blue(project.required_python_version),
                            crayons.blue(python_version(path_to_python) or "unknown"),
                            crayons.green(shorten_path(path_to_python)),
                        ),
                        err=True,
                    )
                    click.echo(
                        "  {0} and rebuilding the virtual environment "
                        "may resolve the issue.".format(crayons.green("$ pipenv --rm")),
                        err=True,
                    )
                    if not deploy:
                        click.echo(
                            "  {0} will surely fail."
                            "".format(crayons.red("$ pipenv check")),
                            err=True,
                        )
                    else: