Skip to content

Commit

Permalink
Merge pull request #324 from paulproteus/create-dot-briefcase-path
Browse files Browse the repository at this point in the history
Add BaseCommand.dot_briefcase_path
  • Loading branch information
freakboy3742 authored Mar 16, 2020
2 parents a768a54 + 3dcdecf commit ba74df0
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/briefcase/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/briefcase/commands/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/briefcase/platforms/linux/appimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 4 additions & 1 deletion tests/commands/create/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/create/test_install_app_support_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)

Expand Down Expand Up @@ -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',
)

Expand Down
5 changes: 4 additions & 1 deletion tests/platforms/linux/appimage/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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...
Expand Down

0 comments on commit ba74df0

Please sign in to comment.