Skip to content

Apps are finalized when they don't have to be= #2654

@freakboy3742

Description

@freakboy3742

Describe the bug

If you run a command such as open, build, or create with the -a option, all apps are finalized, rather than just the app being operated on.

This results in the finalization of configurations that aren't being used. This isn't a huge problem, but it is unnecessary processing.

Steps to reproduce

  1. Generate an empty project configuration for an app with a formal name of App 1
  2. Add the following to the bottom of the generated pyproject.toml:
[tool.briefcase.app.app2]
formal_name = "App2"
description = "My second application"
long_description = """More details about the app should go here.
"""
sources = [
    "src/app2",
]
external_package_path = "something"
  1. Duplicate the app content. From the same directory as pyproject.toml, run:
cp -r src/app1 src/app2

(or the windows equivalent, duplicating src/app1 as src/app2
4. Run briefcase create -a app1.
5. See Error:

Briefcase configuration error: 'app2' is declared as an external app, but also defines 'sources'. External apps (apps defining 'external_package_path') cannot define sources.

This is flagging a valid configuration error in app2; but given that the command is only running app1, this validation should not be performed.

Expected behavior

Finalization for app2 should not be executed when specifying -a app1.

Screenshots

No response

Environment

  • Operating System: All
  • Python version: All
  • Software versions:
    • Briefcase: 0.3.26+

Logs


Additional context

The issue is caused by the sequence of operations for finalize() in the base command. It currently takes a single AppConfig or None; If None is provided, all apps are finalized.

finalize() is invoked passing in an app argument if it is provided - but when -a is used, the app argument will be None, and app_name contains the actual app name.

finalize() should be modified to require a list of AppConfig objects (and not accept None). The updated finalize() command should then be invoked after the list of apps to be processed has been confirmed.

In cases where there is no list of apps (such as new), an empty list should be passed to finalize(); if there can only be one app (e.g., run), a list of one item should be passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA crash or error in behavior.good first issueIs this your first time contributing? This could be a good place to start!

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions