Repository: beeware/briefcase
Pull request #1375 (2023-07-22 16:08:28)

Disable `pip` warnings/checks during `requires` install
## Changes
- Disables some unnecessary (IMO) checks and feedback during app `requires` installation; specifically: 
  - `pip` version checking
  - `pip` Python version compatibility

These are all spurious and unnecessary while building the app. I left them for `briefcase dev`, though, since Briefcase is literally installing in to the user's environment.

## PR Checklist:
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
- [x] All new features have been tested
- [x] All new features have been documented
- [x] I have read the **CONTRIBUTING.md** file
- [x] I will abide by the code of conduct


rmartin16: hmm....seems `pip` on `debian:bullseye` is too old for `--root-user-action`....

Although, that brings up the fact we're using old versions of `pip` in the containers. It may be best to have the Dockerfiles update `pip`...

Briefcase already requires at least `pip >= 23.1.1` and `--root-user-action` was introduced in `22.1`.

Patch:
diff --git a/changes/1375.misc.rst b/changes/1375.misc.rst
new file mode 100644
index 00000000..32d74bf5
--- /dev/null
+++ b/changes/1375.misc.rst
@@ -0,0 +1,1 @@
+To avoid spurious warnings, pip's version check warnings were disabled while installing an app's requirements.
diff --git a/src/briefcase/commands/create.py b/src/briefcase/commands/create.py
index 05ef8705..d04e5c66 100644
--- a/src/briefcase/commands/create.py
+++ b/src/briefcase/commands/create.py
@@ -479,6 +479,8 @@ class CreateCommand(BaseCommand):
                             "-m",
                             "pip",
                             "install",
+                            "--disable-pip-version-check",
+                            "--no-python-version-warning",
                             "--upgrade",
                             "--no-user",
                             f"--target={app_packages_path}",


Test patch:
diff --git a/tests/commands/create/test_install_app_requirements.py b/tests/commands/create/test_install_app_requirements.py
index 97cd61fd..20fc232e 100644
--- a/tests/commands/create/test_install_app_requirements.py
+++ b/tests/commands/create/test_install_app_requirements.py
@@ -123,6 +123,8 @@ def test_app_packages_valid_requires(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -172,6 +174,8 @@ def test_app_packages_valid_requires_no_support_package(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -216,6 +220,8 @@ def test_app_packages_invalid_requires(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -267,6 +273,8 @@ def test_app_packages_offline(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -320,6 +328,8 @@ def test_app_packages_install_requirements(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -383,6 +393,8 @@ def test_app_packages_replace_existing_requirements(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -671,6 +683,8 @@ def test_app_packages_test_requires(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -715,6 +729,8 @@ def test_app_packages_test_requires_test_mode(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
@@ -762,6 +778,8 @@ def test_app_packages_only_test_requires_test_mode(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={app_packages_path}",
diff --git a/tests/platforms/iOS/xcode/test_create.py b/tests/platforms/iOS/xcode/test_create.py
index 38ca71b4..036614a2 100644
--- a/tests/platforms/iOS/xcode/test_create.py
+++ b/tests/platforms/iOS/xcode/test_create.py
@@ -48,6 +48,8 @@ def test_extra_pip_args(create_command, first_app_generated, tmp_path):
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={tmp_path / 'base_path' / 'build' / 'first-app' / 'ios' / 'xcode' / 'app_packages'}",
diff --git a/tests/platforms/iOS/xcode/test_update.py b/tests/platforms/iOS/xcode/test_update.py
index 8d0a3802..33c26051 100644
--- a/tests/platforms/iOS/xcode/test_update.py
+++ b/tests/platforms/iOS/xcode/test_update.py
@@ -35,6 +35,8 @@ def test_extra_pip_args(update_command, first_app_generated, tmp_path):
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={tmp_path / 'base_path' / 'build' / 'first-app' / 'ios' / 'xcode' / 'app_packages'}",
diff --git a/tests/platforms/linux/test_LocalRequirementsMixin.py b/tests/platforms/linux/test_LocalRequirementsMixin.py
index 50e4887c..8de76c1e 100644
--- a/tests/platforms/linux/test_LocalRequirementsMixin.py
+++ b/tests/platforms/linux/test_LocalRequirementsMixin.py
@@ -177,6 +177,8 @@ def test_install_app_requirements_in_docker(create_command, first_app_config, tm
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             "--target=/app/path/to/app_packages",
@@ -230,6 +232,8 @@ def test_install_app_requirements_no_docker(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             f"--target={tmp_path}/base_path/build/first-app/tester/dummy/path/to/app_packages",
@@ -341,6 +345,8 @@ def test_install_app_requirements_with_locals(
             "-m",
             "pip",
             "install",
+            "--disable-pip-version-check",
+            "--no-python-version-warning",
             "--upgrade",
             "--no-user",
             "--target=/app/path/to/app_packages",