diff --git a/pipenv/utils/__init__.py b/pipenv/utils/__init__.py index 80f46ce19b..48d7150358 100644 --- a/pipenv/utils/__init__.py +++ b/pipenv/utils/__init__.py @@ -1,7 +1,7 @@ import logging from pipenv.patched.pip._vendor import rich -` + logging.basicConfig(level=logging.ERROR) console = rich.console.Console() diff --git a/pipenv/utils/pip.py b/pipenv/utils/pip.py index d954d1bc9b..d6ea2f5676 100644 --- a/pipenv/utils/pip.py +++ b/pipenv/utils/pip.py @@ -6,7 +6,7 @@ from pipenv.patched.pip._internal.build_env import get_runnable_pip from pipenv.project import Project -from pipenv.utils import console, err +from pipenv.utils import err from pipenv.utils.dependencies import get_constraints_from_deps, prepare_constraint_file from pipenv.utils.indexes import get_source_list, prepare_pip_source_args from pipenv.utils.processes import subprocess_run @@ -30,15 +30,16 @@ def gen(out): def format_pip_error(error): - error = error.replace("Expected", "[bold green]Expected[/bold green]", fg="green", bold=True))) + error = error.replace("Expected", "[bold green]Expected[/bold green]") error = error.replace("Got", "[bold red]Got[/red bold]") error = error.replace( "THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE", "[bold red]THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock![/bold red]", - ) + ) error = error.replace( "someone may have tampered with them", - "[red]someone may have tampered with them[/red]") + "[red]someone may have tampered with them[/red]", + ) error = error.replace("option to pip install", "option to 'pipenv install'") return error diff --git a/pipenv/utils/pipfile.py b/pipenv/utils/pipfile.py index 605d24b70b..9029c59a3d 100644 --- a/pipenv/utils/pipfile.py +++ b/pipenv/utils/pipfile.py @@ -1,12 +1,8 @@ import os from pipenv import environments, exceptions -from pipenv.patched.pip._vendor import rich +from pipenv.utils import console, err from pipenv.utils.requirements import import_requirements -from pipenv.vendor import click - -console = rich.console.Console() -err = rich.console.Console(stderr=True) def walk_up(bottom): @@ -74,12 +70,9 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False # If there's a requirements file, but no Pipfile... if project.requirements_exists and not skip_requirements: requirements_dir_path = os.path.dirname(project.requirements_location) - click.echo( - "{} found in {} instead of {}! Converting...".format( - click.style("requirements.txt", bold=True), - click.style(requirements_dir_path, fg="yellow", bold=True), - click.style("Pipfile", bold=True), - ) + console.print( + f"[bold]requirements.txt[/bold] found in [bold yellow]{requirements_dir_path}" + "[/bold yellow] instead of [bold]Pipfile[/bold]! Converting..." ) # Create a Pipfile... project.create_pipfile(python=python) @@ -96,18 +89,14 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False environments.PIPENV_SPINNER_OK_TEXT.format("Success!") ) # Warn the user of side-effects. - click.echo( - "{0}: Your {1} now contains pinned versions, if your {2} did. \n" - "We recommend updating your {1} to specify the {3} version, instead." - "".format( - click.style("Warning", fg="red", bold=True), - click.style("Pipfile", bold=True), - click.style("requirements.txt", bold=True), - click.style('"*"', bold=True), - ) + console.print( + "[bold red]Warning[/bold red]: Your [bold]Pipfile[/bold] now contains pinned versions, " + "if your [bold]requirements.txt[/bold] did. \n" + 'We recommend updating your [bold]Pipfile[/bold] to specify the [bold]"*"' + "[/bold] version, instead." ) else: - click.secho("Creating a Pipfile for this project...", bold=True, err=True) + err.print("Creating a Pipfile for this project...", style="bold") # Create the pipfile if it doesn't exist. project.create_pipfile(python=python) # Validate the Pipfile's contents. @@ -117,7 +106,5 @@ def ensure_pipfile(project, validate=True, skip_requirements=False, system=False changed = project.ensure_proper_casing() # Write changes out to disk. if changed: - click.echo( - click.style("Fixing package names in Pipfile...", bold=True), err=True - ) + err.print("Fixing package names in Pipfile...", style="bold") project.write_toml(p)