meta_package_manager.managers.mas module¶
- class meta_package_manager.managers.mas.MAS[source]¶
Bases:
PackageManagermasdrives the Mac App Store from the command line.Packages are Mac App Store applications, keyed by the numeric adamID Apple assigns each title (the
idin an App Store link). mpm reads and writes that ID; the display name rides along only as a label.Every query reads
--jsonoutput, the supported programmatic interface since the>=7.0.0floor added--jsontolist,outdatedandsearch.Note
masself-escalates: it asks for root itself when a store mutation needs it, so mpm never wrapsinstall,upgradeoruninstallin its ownsudo.Initialize
cli_errorslist.- name: str = 'Mac App Store'¶
Return package manager’s common name.
Default value is based on class name.
- repository_url: str | None = 'https://github.com/mas-cli/mas'¶
Repository holding the project’s code, or
Nonewhen it has no public one.Linked from the manager’s documentation page. Also what the weekly metrics sample reads:
docs/docs_update.pywrites it into the[tool.repomatic.metrics] subjectsofpyproject.tomlwhen its forge answers the sampler, through a mirror for a forge that does not.Never inherited, for the same reason as
wikipedia_url: the AUR helpers extendingpacmaneach live in a repository of their own.
- logo: str | None = 'appstore'¶
Slug of the brand mark standing for this manager in the documentation.
Names an SVG vendored under
docs/assets/managers/, whose provenance and license are recorded indocs/assets/managers/logos.yaml. Inlined at the top of the manager’s page bymeta_package_manager._docs; a manager leaving it unset keeps the page’s default package glyph.Several managers legitimately share one slug, either because they wrap the same upstream (
brewandcask) or because the tool has no mark of its own and its ecosystem’s stands in (aptunder Debian’s swirl,cargounder Rust’s gear). Documentation-only, likehomepage_url: no CLI output reads it.
- keywords: tuple[str, ...] = ('app store', 'app-store')¶
Well-known names for this manager that its
iddoes not already carry.Merged into the PyPI keywords of
pyproject.tomlbyupdate_keywords()ofdocs/docs_update.py, alongside every manager ID and the globally curatedKEYWORDS_EXTRAS. Declare an alias here rather than in that tuple whenever it names this manager: an alias living beside the class it describes cannot outlive it, where a central entry silently rots once the manager is renamed or dropped.Reserve
KEYWORDS_EXTRASfor terms belonging to no manager in particular, likecyclonedxorpackage manager. Documentation-only: no CLI output reads it.Each keyword also becomes a content rule of the issue labeller, so its precision bar applies here: see
generate_content_rules(). A subclass inherits the terms of its parent without claiming them, sincetest_manager_keywords_have_one_ownerreads what a class declares itself.
- brewfile_entry_type: ClassVar[str | None] = 'mas'¶
Name of the Brewfile DSL entry type this manager maps to, or
Noneif the manager has no Brewfile equivalent.Set by the subset of managers Homebrew Bundle’s DSL covers, and consumed by
meta_package_manager.brewfilewhen rendering the output ofmpm dump --brewfile. Which manager maps to which entry is tabulated from these declarations in Snapshot and export, section “Brewfile”, where the export’s own quirks are documented too.
- platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='macos', name='macOS')})¶
List of platforms supported by the manager.
Allows for a mishmash of platforms and groups of platforms. Will be normalized into a
frozensetofPlatforminstances at instantiation.
- requirement: str | None = '>=7.0.0'¶
7.0.0 introduces the
--jsonflag onconfig,list,lookup/info,outdated&search. Parsing structured JSON output is the supported programmatic interface: it sidesteps the column-alignment ambiguities of the tabular output (app names containing parentheses or extra whitespace would break the previous regex-based parser).
- brewfile_entry(package)[source]¶
Emit the app’s display name, with its numeric adamID as the
id:keywordbrew bundleinstalls from.Returns
None(silently skip) for any package whose ID is not such a number: without it the entry cannot round-trip, and a half-brokenmas "Name"line would error at install time. See Snapshot and export, section “masentries”.
- property installed: Iterator[Package]¶
Fetch installed packages.
$ mas list --json {"adamID":1569813296,"bundleID":"com.1password.1password-safari","name":"1Password for Safari","version":"2.3.5"} {"adamID":1295203466,"bundleID":"com.microsoft.rdc.macos","name":"Microsoft Remote Desktop","version":"10.7.6"} {"adamID":409183694,"bundleID":"com.apple.iWork.Keynote","name":"Keynote","version":"12.0"}
- property outdated: Iterator[Package]¶
Fetch outdated packages.
$ mas outdated --json {"adamID":409183694,"name":"Keynote","newVersion":"12.0","version":"11.0"} {"adamID":1176895641,"name":"Spark","newVersion":"2.11.21","version":"2.11.20"}
- release_date(package_id)[source]¶
Publication timestamp of the latest release of an app, read from the App Store catalog.
mas lookup --jsonrelays the App Store’s own catalog record, whosecurrentVersionReleaseDateis stamped by the store when the version goes live after review, not by the app’s author, which is what makes it a sound cooldown clock. App Review already delays every release on its own, so the window mostly buys time between a version going live and a takedown.$ mas lookup 409183694 --json {"adamID":409183694,"bundleID":"com.apple.iWork.Keynote","currentVersionReleaseDate":"2024-04-02T17:19:42Z","name":"Keynote","version":"14.0"}
- search(query, extended, exact)[source]¶
Fetch matching packages.
Caution
Search does not support extended or exact matching. So we return the best subset of results and let
meta_package_manager.manager.PackageManager.refiltered_search()refine them.$ mas search python --json {"adamID":689176796,"name":"Python Runner","version":"1.3"} {"adamID":630736088,"name":"Learning Python","version":"1.0"} {"adamID":945397020,"name":"Run Python","version":"1.0"} {"adamID":1164498373,"name":"PythonGames","version":"1.0"} {"adamID":1400050251,"name":"Pythonic","version":"1.0.0"}
- install(package_id, version=None)[source]¶
Install one package.
$ mas install 945397020
- Return type:
- cli_names: tuple[str, ...] = ('mas',)¶
List of CLI names the package manager is known as.
This list of recognized CLI names is ordered by priority. That way we can influence the search of the right binary.
- ..hint::
This was helpful in the case of the Python transition from 2.x to 3.x, where multiple versions of the same executable were named
pythonorpython3.
By default, this property’s value is derived from the manager’s ID (see the
MetaPackageManager.__init__method above).
- documentation_url: str | None = None¶
Entry point of the project’s own documentation, or
Nonewhen it has none.The manual, the documentation site, or the man page of the CLI
mpmdrives: whichever page a user reads to learn the commands this manager wraps. Listed betweenhomepage_urlandrepository_urlin the links of the manager’s page, so a reader reaching for the tool’s reference finds it in the box of facts rather than in the prose below it.Left unset where a link would state a fact twice or invent one: a tool documenting itself in its repository alone, whose README
repository_urlalready reaches. A page about the ecosystem rather than the tool does not qualify either.Where a project’s only site is its manual, that address belongs here and
homepage_urlstays unset: the slot names what the page is, and a reader reaching for the reference looks under the documentation link.Never inherited, like every other link: the AUR helpers extending
pacmaneach document themselves.
- homepage_url: str | None = None¶
Home page of the project, only used in documentation for reference.
Left unset when the home page is the project’s repository, which
repository_urlnames on its own, and when it is the project’s manual, whichdocumentation_urlnames. Never inherited, like the other links.
- id: str = 'mas'¶
Package manager’s ID.
Derived by defaults from the lower-cased class name in which underscores
_are replaced by dashes-.This ID must be unique among all package manager definitions and lower-case, as they’re used as feature flags for the mpm CLI.
- upgrade_one_cli(package_id, version=None)[source]¶
Generates the CLI to upgrade the provided package.
$ mas upgrade 945397020
- virtual: bool = False¶
Should we expose the package manager to the user?
Virtual package manager are just skeleton classes used to factorize code among managers of the same family.
- wikipedia_url: str | None = None¶
English Wikipedia article about the project, or
Nonewhen it has none.Listed last in the links of the manager’s documentation page. The article covers the project that home page names, or is a redirect Wikipedia keeps under the project’s name, landing on the part of a broader article that describes it:
Cargo_(software)opens the Cargo section of the Rust article. An article that merely mentions the project does not count, nor does one about a related subject:lazyis a Neovim plugin manager, and the Neovim article is not about it.Never inherited: the metaclass resets it to
Noneon any class not declaring its own. A subclass often wraps a distinct project, like the six AUR helpers extendingpacman, and would otherwise present pacman’s article as its own. Documentation-only, likehomepage_url.
- remove(package_id)[source]¶
Removes a package.
mas4.1.0+ requests root privileges itself when not already running as root, so we don’t pre-wrap the call insudo. This matches howinstallandupgradeare already invoked.$ mas uninstall 1494051017 Password: Uninstalled '/Applications/SimpleLogin.app' to '/Users/kde/.Trash/SimpleLogin.app'
- Return type: