meta_package_manager.brewfile module¶
Render the installed-package inventory as a Brewfile.
Defines build_brewfile() and the helpers used by mpm dump --brewfile
to emit a Brewfile that brew bundle install can consume.
Note
Brewfile is a Ruby DSL. The format reference is the Homebrew Bundle source at
Library/Homebrew/bundle/dsl.rb and the extensions under
Library/Homebrew/bundle/extensions/ (brew 6.0.0+).
- meta_package_manager.brewfile.BUNDLE_ENTRY_TYPES: tuple[str, ...] = ('tap', 'brew', 'cask', 'mas', 'vscode', 'npm', 'cargo', 'uv', 'winget', 'flatpak')¶
Canonical emission order of Brewfile sections.
Mirrors the registration order of
Homebrew::Bundle.dump_package_typesand the extensions underLibrary/Homebrew/bundle/extensions/.tapalways comes first so that any third-party tap a downstreambreworcaskentry references is registered before the install step runs.
- meta_package_manager.brewfile.DEFAULT_TAPS: frozenset[tuple[str, str]] = frozenset({('homebrew', 'cask'), ('homebrew', 'core')})¶
Taps that
brewenables by default. Never emitted as explicittaplines.
- meta_package_manager.brewfile.quote(value)[source]¶
Ruby-compatible double-quoted string literal.
brew bundle dumpuses Ruby’sString#inspect: double quotes with backslash escapes for control characters and unicode.json.dumps(..., ensure_ascii=False)produces the same output for ASCII content and a Ruby-parseable double-quoted string for non-ASCII codepoints.- Return type:
- meta_package_manager.brewfile.format_entry(entry_type, name, options=None)[source]¶
Render a single Brewfile DSL line.
Supports the two shapes
Homebrew::Bundle::Extensions::Extension.dump_entryemits:bare:
brew "git"with options:
mas "Xcode", id: 497799835orflatpak "org.mozilla.firefox", with: ["flathub"]
- Return type:
- meta_package_manager.brewfile.format_header(coverage, skipped, platform)[source]¶
Render the comment block at the top of a Brewfile dump.
- Return type:
- meta_package_manager.brewfile.tap_from_package_id(package_id)[source]¶
Return
user/tapifpackage_idis tap-qualified, elseNone.Default taps in
DEFAULT_TAPSare filtered out: those are always enabled bybrewand emittingtaplines for them would be noise.
- meta_package_manager.brewfile.build_brewfile(managers, *, packages_by_manager=None, include_header=True, skipped_counts=None, platform='')[source]¶
Render a Brewfile from the given managers’ installed packages.
Only managers whose
brewfile_entry_typeis set contribute output; the caller is expected to have filtered the iterable accordingly, but managers without a configured entry type are silently skipped as a defensive measure.packages_by_manager(keyed by manager id) supplies each manager’s installed packages so the caller can fetch them concurrently up front. When omitted, each manager’sinstalledis queried inline instead (the path the unit tests exercise).skipped_countsis a per-manager-id tally of packages excluded because their manager has no Brewfile mapping; it is rendered in the header for visibility.- Return type: