Skip to content

Commit

Permalink
Merge pull request #1708 from rmartin16/pip-verbose
Browse files Browse the repository at this point in the history
Run `pip` verbosely in deep debug mode
  • Loading branch information
freakboy3742 committed Mar 24, 2024
2 parents 84f7600 + 18768f9 commit 52dd46d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions changes/1708.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
When deep debug is activated via ``-vv``, ``pip`` now installs requirements for the app with verbose logging.
1 change: 1 addition & 0 deletions src/briefcase/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ def _pip_install(
"--no-user",
f"--target={app_packages_path}",
]
+ (["-vv"] if self.logger.is_deep_debug else [])
+ self._extra_pip_args(app)
+ pip_args,
check=True,
Expand Down
1 change: 1 addition & 0 deletions src/briefcase/commands/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def install_dev_requirements(self, app: AppConfig, **options):
"install",
"--upgrade",
]
+ (["-vv"] if self.logger.is_deep_debug else [])
+ requires,
check=True,
encoding="UTF-8",
Expand Down
3 changes: 2 additions & 1 deletion src/briefcase/platforms/web/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ def build_app(self, app: AppConfig, **kwargs):
self.wheel_path(app),
"-r",
self.bundle_path(app) / "requirements.txt",
],
]
+ (["-vv"] if self.logger.is_deep_debug else []),
check=True,
encoding="UTF-8",
)
Expand Down
12 changes: 8 additions & 4 deletions tests/commands/create/test_install_app_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import tomli_w

from briefcase.commands.create import _is_local_requirement
from briefcase.console import LogLevel
from briefcase.exceptions import BriefcaseCommandError, RequirementsInstallError
from briefcase.integrations.subprocess import Subprocess

Expand Down Expand Up @@ -285,13 +286,17 @@ def test_app_packages_offline(
assert myapp.test_requires is None


@pytest.mark.parametrize("logging_level", [LogLevel.INFO, LogLevel.DEEP_DEBUG])
def test_app_packages_install_requirements(
create_command,
myapp,
app_packages_path,
app_packages_path_index,
logging_level,
):
"""Requirements can be installed."""
# Configure logging level
create_command.logger.verbosity = logging_level

# Set up the app requirements
myapp.requires = ["first", "second", "third"]
Expand Down Expand Up @@ -319,10 +324,9 @@ def test_app_packages_install_requirements(
"--upgrade",
"--no-user",
f"--target={app_packages_path}",
"first",
"second",
"third",
],
]
+ (["-vv"] if logging_level == LogLevel.DEEP_DEBUG else [])
+ ["first", "second", "third"],
check=True,
encoding="UTF-8",
)
Expand Down
14 changes: 9 additions & 5 deletions tests/commands/dev/test_install_dev_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@

import pytest

from briefcase.console import LogLevel
from briefcase.exceptions import RequirementsInstallError


def test_install_requirements_no_error(dev_command, first_app):
@pytest.mark.parametrize("logging_level", [LogLevel.INFO, LogLevel.DEEP_DEBUG])
def test_install_requirements_no_error(dev_command, first_app, logging_level):
"""Ensure run is executed properly to install requirements."""
# Configure logging level
dev_command.logger.verbosity = logging_level

first_app.requires = ["package-one", "package_two", "packagethree"]

dev_command.install_dev_requirements(app=first_app)
Expand All @@ -22,10 +27,9 @@ def test_install_requirements_no_error(dev_command, first_app):
"pip",
"install",
"--upgrade",
"package-one",
"package_two",
"packagethree",
],
]
+ (["-vv"] if logging_level == LogLevel.DEEP_DEBUG else [])
+ ["package-one", "package_two", "packagethree"],
check=True,
encoding="UTF-8",
)
Expand Down
11 changes: 8 additions & 3 deletions tests/platforms/web/static/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import pytest

from briefcase.console import Console, Log
from briefcase.console import Console, Log, LogLevel
from briefcase.exceptions import BriefcaseCommandError, BriefcaseConfigError
from briefcase.integrations.subprocess import Subprocess
from briefcase.platforms.web.static import StaticWebBuildCommand
Expand All @@ -32,8 +32,12 @@ def build_command(tmp_path):
return command


def test_build_app(build_command, first_app_generated, tmp_path):
@pytest.mark.parametrize("logging_level", [LogLevel.INFO, LogLevel.DEEP_DEBUG])
def test_build_app(build_command, first_app_generated, logging_level, tmp_path):
"""An app can be built."""
# Configure logging level
build_command.logger.verbosity = logging_level

bundle_path = tmp_path / "base_path/build/first-app/web/static"

# Invoking build will create wheels as a side effect.
Expand Down Expand Up @@ -110,7 +114,8 @@ def mock_run(*args, **kwargs):
bundle_path / "www/static/wheels",
"-r",
bundle_path / "requirements.txt",
],
]
+ (["-vv"] if logging_level == LogLevel.DEEP_DEBUG else []),
check=True,
encoding="UTF-8",
),
Expand Down

0 comments on commit 52dd46d

Please sign in to comment.