Repository: beeware/briefcase
Pull request #1929 (2024-07-26 18:16:14)

Use stripped versions of Standalone Python for Linux
## Changes
- Version [20240726](https://github.com/indygreg/python-build-standalone/releases/tag/20240726) of Standalone Python now includes stripped versions
- Introduces minimum target version 0.3.20 for Flatpak and AppImage since only newer versions of Standalone Python provided the stripped versions.

## Notes
- Merge the PRs below first and re-run CI here:
  - https://github.com/beeware/briefcase-linux-flatpak-template/pull/46
  - https://github.com/beeware/briefcase-linux-appimage-template/pull/52

## 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


Patch:
diff --git a/changes/1929.feature.rst b/changes/1929.feature.rst
new file mode 100644
index 00000000..472dd681
--- /dev/null
+++ b/changes/1929.feature.rst
@@ -0,0 +1,1 @@
+Apps packaged for Flatpak and AppImage now use a stripped (and smaller) Python support package.
diff --git a/src/briefcase/platforms/linux/__init__.py b/src/briefcase/platforms/linux/__init__.py
index 63ec625d..f1265ead 100644
--- a/src/briefcase/platforms/linux/__init__.py
+++ b/src/briefcase/platforms/linux/__init__.py
@@ -77,7 +77,8 @@ class LinuxMixin:
         version, datestamp = support_revision.split("+")
         return (
             "https://github.com/indygreg/python-build-standalone/releases/download/"
-            f"{datestamp}/cpython-{support_revision}-{python_download_arch}-unknown-linux-gnu-install_only.tar.gz"
+            f"{datestamp}/"
+            f"cpython-{support_revision}-{python_download_arch}-unknown-linux-gnu-install_only_stripped.tar.gz"
         )
 
     def vendor_details(self, freedesktop_info):
diff --git a/src/briefcase/platforms/linux/appimage.py b/src/briefcase/platforms/linux/appimage.py
index 0a302ec6..73743aa1 100644
--- a/src/briefcase/platforms/linux/appimage.py
+++ b/src/briefcase/platforms/linux/appimage.py
@@ -36,6 +36,7 @@ class LinuxAppImagePassiveMixin(LinuxMixin):
     supported_host_os_reason = (
         "Linux AppImages can only be built on Linux, or on macOS using Docker."
     )
+    platform_target_version = "0.3.20"
 
     def appdir_path(self, app):
         return self.bundle_path(app) / f"{app.formal_name}.AppDir"
diff --git a/src/briefcase/platforms/linux/flatpak.py b/src/briefcase/platforms/linux/flatpak.py
index d996a23c..563248b0 100644
--- a/src/briefcase/platforms/linux/flatpak.py
+++ b/src/briefcase/platforms/linux/flatpak.py
@@ -19,6 +19,7 @@ class LinuxFlatpakMixin(LinuxMixin):
     output_format = "flatpak"
     supported_host_os = {"Linux"}
     supported_host_os_reason = "Flatpaks can only be built on Linux."
+    platform_target_version = "0.3.20"
 
     def binary_path(self, app):
         # Flatpak doesn't really produce an identifiable "binary" as part of its


Test patch:
diff --git a/tests/platforms/linux/appimage/test_build.py b/tests/platforms/linux/appimage/test_build.py
index 26360a7d..fddf0eec 100644
--- a/tests/platforms/linux/appimage/test_build.py
+++ b/tests/platforms/linux/appimage/test_build.py
@@ -51,12 +51,6 @@ def build_command(tmp_path, first_app_config):
     command.tools.host_arch = "x86_64"
     command.use_docker = False
     command.extra_docker_build_args = []
-    command._briefcase_toml[first_app_config] = {
-        "paths": {
-            "app_path": "First App.AppDir/usr/app",
-            "app_packages_path": "First App.AppDir/usr/app_packages",
-        }
-    }
 
     # Reset `os` mock without `spec` so tests can run on Windows where os.getuid doesn't exist.
     command.tools.os = mock.MagicMock()
@@ -558,11 +552,12 @@ def test_build_appimage_with_support_package_update(
     # Populate a briefcase.toml that mirrors a real Windows app
     with (build_command.bundle_path(first_app) / "briefcase.toml").open("wb") as f:
         index = {
+            "briefcase": {"target_version": "0.3.20"},
             "paths": {
                 "app_path": "First App.AppDir/usr/app",
                 "app_package_path": "First App.AppDir/usr/app_packages",
                 "support_path": "First App.AppDir/usr",
-            }
+            },
         }
         tomli_w.dump(index, f)
 
diff --git a/tests/platforms/linux/test_LinuxMixin__support_package_url.py b/tests/platforms/linux/test_LinuxMixin__support_package_url.py
index 93b64b19..630015c1 100644
--- a/tests/platforms/linux/test_LinuxMixin__support_package_url.py
+++ b/tests/platforms/linux/test_LinuxMixin__support_package_url.py
@@ -8,43 +8,43 @@ import pytest
             "3.10.9+20230116",
             "x86_64",
             False,
-            "20230116/cpython-3.10.9+20230116-x86_64-unknown-linux-gnu-install_only.tar.gz",
+            "20230116/cpython-3.10.9+20230116-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.11.1+20230116",
             "aarch64",
             False,
-            "20230116/cpython-3.11.1+20230116-aarch64-unknown-linux-gnu-install_only.tar.gz",
+            "20230116/cpython-3.11.1+20230116-aarch64-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.11.1+20230116",
             "aarch64",
             True,
-            "20230116/cpython-3.11.1+20230116-armv7-unknown-linux-gnu-install_only.tar.gz",
+            "20230116/cpython-3.11.1+20230116-armv7-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.11.1+20230116",
             "armv7l",
             True,
-            "20230116/cpython-3.11.1+20230116-armv7l-unknown-linux-gnu-install_only.tar.gz",
+            "20230116/cpython-3.11.1+20230116-armv7l-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.8.16+20221220",
             "x86_64",
             False,
-            "20221220/cpython-3.8.16+20221220-x86_64-unknown-linux-gnu-install_only.tar.gz",
+            "20221220/cpython-3.8.16+20221220-x86_64-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.8.16+20221220",
             "x86_64",
             True,
-            "20221220/cpython-3.8.16+20221220-i686-unknown-linux-gnu-install_only.tar.gz",
+            "20221220/cpython-3.8.16+20221220-i686-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
         (
             "3.8.16+20221220",
             "i686",
             True,
-            "20221220/cpython-3.8.16+20221220-i686-unknown-linux-gnu-install_only.tar.gz",
+            "20221220/cpython-3.8.16+20221220-i686-unknown-linux-gnu-install_only_stripped.tar.gz",
         ),
     ],
 )