Skip to content

Running pip install . in a Briefcase project causes error "application must have a formal name" #2583

@NMertsch

Description

@NMertsch

What is the problem or limitation you are having?

After running pip install . in a briefcase project using toga, briefcase dev will crash with "Toga application must have a formal name". That's quite confusing and not helpful.

Why does this happen?

  • pyproject.toml is present, so pip recognizes the directory as a valid Python package.
  • pyproject.toml does not contain PEP 621 project metadata (section project), so pip uses default values: Version: 0.0.0, Name: <your-project-dirname>.
    • pip does NOT pick up the briefcase project metadata from the section tool.briefcase.
  • pip creates src/<your-package>.egg-info/ containing this minimal set of project metadata.
  • briefcase dev creates src/<your-package>.dist-info/ with the correct metadata
  • toga.app.App.__init__() uses importlib.metadata.metadata(sys.modules["__main__"].__package__).get("Formal-Name") to get the Format-Name metadata, which is not present in the egg-info, so it raises a RuntimeError.

Maybe the tutorial should be clearer about when to use pip vs when not to use pip.

Describe the solution you'd like

I don't know enough about Python packaging, metadata discovery, egg-info vs dist-info and probably other relevant topics. I hope that someone else can pick up from here to find a solution.

Describe alternatives you've considered

Potential approaches (some way be wrong/bad/impossible):

  • briefcase dev aborts with a useful error message if egg-info exists.
  • briefcase dev ignores egg-info, so toga uses the correct metadata from dist-info.
  • pip install . fails instead of being "accidentally successful".
  • pip install . finds the correct metadata.
  • briefcase dev creates/overwrites egg-info instead of dist-info.
  • Update the tutorial to provide better guidance on when to use and not to use pip vs briefcase vs modifying pyproject.toml.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features, or improvements to existing features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions