From f83960e4527ed2630c7c7fd181b9d65f77bc8536 Mon Sep 17 00:00:00 2001 From: Asheesh Laroia Date: Sun, 15 Mar 2020 11:47:18 -0700 Subject: [PATCH 1/2] Add BaseCommand.dot_briefcase_path --- src/briefcase/commands/base.py | 8 +++++++- src/briefcase/commands/create.py | 2 +- src/briefcase/platforms/linux/appimage.py | 2 +- tests/commands/create/conftest.py | 5 ++++- tests/commands/create/test_install_app_support_package.py | 4 ++-- tests/platforms/linux/appimage/test_build.py | 5 ++++- 6 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/briefcase/commands/base.py b/src/briefcase/commands/base.py index 73ea4aa9c..7b5d25dd9 100644 --- a/src/briefcase/commands/base.py +++ b/src/briefcase/commands/base.py @@ -111,8 +111,14 @@ class BaseCommand(ABC): GLOBAL_CONFIG_CLASS = GlobalConfig APP_CONFIG_CLASS = AppConfig - def __init__(self, base_path, apps=None): + def __init__( + self, + base_path, + dot_briefcase_path=Path.home() / ".briefcase", + apps=None, + ): self.base_path = base_path + self.dot_briefcase_path = dot_briefcase_path self.global_config = None self.apps = {} if apps is None else apps diff --git a/src/briefcase/commands/create.py b/src/briefcase/commands/create.py index d9f97f713..bd78a0b4a 100644 --- a/src/briefcase/commands/create.py +++ b/src/briefcase/commands/create.py @@ -382,7 +382,7 @@ def install_app_support_package(self, app: BaseConfig): # in the user's briefcase support cache directory. support_filename = self.download_url( url=support_package_url, - download_path=Path.home() / '.briefcase' / 'support' + download_path=self.dot_briefcase_path / 'support' ) else: support_filename = support_package_url diff --git a/src/briefcase/platforms/linux/appimage.py b/src/briefcase/platforms/linux/appimage.py index b0541287f..f66ae78f4 100644 --- a/src/briefcase/platforms/linux/appimage.py +++ b/src/briefcase/platforms/linux/appimage.py @@ -80,7 +80,7 @@ def verify_tools(self): print("Ensure we have the linuxdeploy AppImage...") self.linuxdeploy_appimage = self.download_url( url=self.linuxdeploy_download_url, - download_path=Path.home() / '.briefcase' / 'tools' + download_path=self.dot_briefcase_path / 'tools' ) self.os.chmod(str(self.linuxdeploy_appimage), 0o755) except requests_exceptions.ConnectionError: diff --git a/tests/commands/create/conftest.py b/tests/commands/create/conftest.py index d70b79d3c..db34f8f28 100644 --- a/tests/commands/create/conftest.py +++ b/tests/commands/create/conftest.py @@ -89,7 +89,10 @@ def install_app_resources(self, app): @pytest.fixture def create_command(tmp_path): - return DummyCreateCommand(base_path=tmp_path) + return DummyCreateCommand( + base_path=tmp_path, + dot_briefcase_path=tmp_path / "dot-briefcase", + ) @pytest.fixture diff --git a/tests/commands/create/test_install_app_support_package.py b/tests/commands/create/test_install_app_support_package.py index a2429957e..516bd721d 100644 --- a/tests/commands/create/test_install_app_support_package.py +++ b/tests/commands/create/test_install_app_support_package.py @@ -24,7 +24,7 @@ def test_install_app_support_package(create_command, myapp, tmp_path, support_pa # Confirm the right URL was used create_command.download_url.assert_called_with( - download_path=Path.home() / '.briefcase' / 'support', + download_path=create_command.dot_briefcase_path / 'support', url='https://briefcase-support.org/python?platform=tester&version=3.X', ) @@ -83,7 +83,7 @@ def test_install_custom_app_support_package_url(create_command, myapp, tmp_path, # Confirm the right URL was used create_command.download_url.assert_called_with( - download_path=Path.home() / '.briefcase' / 'support', + download_path=create_command.dot_briefcase_path / 'support', url='https://example.com/custom/support.zip', ) diff --git a/tests/platforms/linux/appimage/test_build.py b/tests/platforms/linux/appimage/test_build.py index 6e6af767b..2d98f975e 100644 --- a/tests/platforms/linux/appimage/test_build.py +++ b/tests/platforms/linux/appimage/test_build.py @@ -13,6 +13,9 @@ def build_command(tmp_path, first_app_config): command = LinuxAppImageBuildCommand( base_path=tmp_path, + # `dot-briefcase` below makes it easy to find references to literal + # `.briefcase` when grepping the source. + dot_briefcase_path=tmp_path / "dot-briefcase", apps={'first': first_app_config} ) command.host_os = 'Linux' @@ -96,7 +99,7 @@ def test_verify_tools_download_failure(build_command): # The download was attempted build_command.download_url.assert_called_with( url='https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-wonky.AppImage', - download_path=Path.home() / '.briefcase' / 'tools' + download_path=build_command.dot_briefcase_path / 'tools' ) # But it failed, so the file won't be made executable... From 3dcdecfdc243adb2fb5804fbd95cf9475b8a058d Mon Sep 17 00:00:00 2001 From: Asheesh Laroia Date: Sun, 15 Mar 2020 19:30:42 -0700 Subject: [PATCH 2/2] Move paren to mollify linter --- src/briefcase/commands/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/briefcase/commands/base.py b/src/briefcase/commands/base.py index 7b5d25dd9..92b47895a 100644 --- a/src/briefcase/commands/base.py +++ b/src/briefcase/commands/base.py @@ -116,7 +116,7 @@ def __init__( base_path, dot_briefcase_path=Path.home() / ".briefcase", apps=None, - ): + ): self.base_path = base_path self.dot_briefcase_path = dot_briefcase_path