meta_package_manager.managers.ghcup module¶
- class meta_package_manager.managers.ghcup.GHCup[source]¶
Bases:
PackageManagerHaskell toolchain installer, covering GHC and the tools built around it.
ghcup installs several kinds of tool side by side: GHC itself, plus
cabal,hls,stackand whatever else its metadata offers. All of them are packages here, becauseghcup listreports every kind in one flat listing whose every line names its own kind, and becauseinstall,rm,setandwhereisall take the same<tool> <version>pair. Reporting only GHC versions would hide from the inventory tools mpm remains perfectly able to install and remove.A package is therefore identified as
<tool>-<version>, and split back on its first hyphen to rebuild the pair. First rather than last is load-bearing: a cross-compiling GHC renders its target into the version cell, soghc-aarch64-unknown-linux-gnu-9.4.8has to split intoghcandaarch64-unknown-linux-gnu-9.4.8, and that remainder is exactly the token ghcup’s own version parser accepts. No tool name contains a hyphen today.Note
Every listing forces
--show-revisions none. ghcup otherwise appends a-rNmetadata-revision suffix to versions that have one, and that suffixed string is not a versionghcup rmwill match: the inventory would then report packages that cannot be removed. The suffix appears only while a revision is pending, so the corruption is intermittent, which is worse than a consistent one.Caution
Neither upgrade operation is declared, and neither is an oversight.
ghcup upgradeupgrades the ghcup binary itself, not the tools it installs, so mapping it ontoupgrade --allwould replace the user’s package manager when they asked to upgrade their packages. And ghcup has no in-place upgrade for a tool at all: a newer GHC is a fresh side-by-side install that leaves the old one in place, which is whatinstallalready does.Note
No
outdatedeither, for a reason that follows from the package identity above rather than from any missing command. Since the version is part of the id, a package having a newer version is a contradiction: the newer version is a different package, installed alongside rather than over. A report pairingghc-9.6.7with a latest of9.10.1would also name an upgrade mpm cannot perform, both upgrade operations being absent. ghcup’s own new-version notice is no help here: it is prose on stderr, it deduplicates itself against a cache file so a second run prints nothing, and it fires as a side effect of unrelated commands.Documentation: ghcup user guide.
Initialize
cli_errorslist.- name: str = 'Haskell ghcup'¶
Return package manager’s common name.
Default value is based on class name.
- homepage_url: str | None = 'https://www.haskell.org/ghcup/'¶
Home page of the project, only used in documentation for reference.
- logo: str | None = 'haskell'¶
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.
- platforms: frozenset[Platform] | Group | Platform | Iterable[Platform | Group] = frozenset({Platform(id='almalinux', name='AlmaLinux'), Platform(id='alpine', name='Alpine Linux'), Platform(id='altlinux', name='ALT Linux'), Platform(id='amzn', name='Amazon Linux'), Platform(id='android', name='Android'), Platform(id='arch', name='Arch Linux'), Platform(id='buildroot', name='Buildroot'), Platform(id='cachyos', name='CachyOS'), Platform(id='centos', name='CentOS'), Platform(id='chromeos', name='ChromeOS'), Platform(id='clearlinux', name='Clear Linux OS'), Platform(id='cloudlinux', name='CloudLinux OS'), Platform(id='debian', name='Debian'), Platform(id='endeavouros', name='EndeavourOS'), Platform(id='exherbo', name='Exherbo Linux'), Platform(id='fedora', name='Fedora'), Platform(id='generic_linux', name='Generic Linux'), Platform(id='gentoo', name='Gentoo Linux'), Platform(id='guix', name='Guix System'), Platform(id='ibm_powerkvm', name='IBM PowerKVM'), Platform(id='kali', name='Kali Linux'), Platform(id='kvmibm', name='KVM for IBM z Systems'), Platform(id='linuxmint', name='Linux Mint'), Platform(id='macos', name='macOS'), Platform(id='mageia', name='Mageia'), Platform(id='mandriva', name='Mandriva Linux'), Platform(id='manjaro', name='Manjaro Linux'), Platform(id='nixos', name='NixOS'), Platform(id='nobara', name='Nobara'), Platform(id='opensuse', name='openSUSE'), Platform(id='openwrt', name='OpenWrt'), Platform(id='oracle', name='Oracle Linux'), Platform(id='parallels', name='Parallels'), Platform(id='pidora', name='Pidora'), Platform(id='pikaos', name='PikaOS'), Platform(id='raspbian', name='Raspbian'), Platform(id='rhel', name='RedHat Enterprise Linux'), Platform(id='rocky', name='Rocky Linux'), Platform(id='scientific', name='Scientific Linux'), Platform(id='slackware', name='Slackware'), Platform(id='sles', name='SUSE Linux Enterprise Server'), Platform(id='slitaz', name='SliTaz GNU/Linux'), Platform(id='sourcemage', name='Source Mage GNU/Linux'), Platform(id='tuxedo', name='Tuxedo OS'), Platform(id='ubuntu', name='Ubuntu'), Platform(id='ultramarine', name='Ultramarine'), Platform(id='void', name='Void Linux'), Platform(id='windows', name='Windows'), Platform(id='wsl1', name='Windows Subsystem for Linux v1'), Platform(id='wsl2', name='Windows Subsystem for Linux v2'), Platform(id='xenserver', name='XenServer')})¶
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 = '>=0.2.1.0'¶
First release accepting
--show-revisions, which every listing needs to keep the-rNsuffix out of versions that must round-trip toghcup rm.Higher than the release the parsers themselves would need, and deliberately so: ghcup is installed by its own bootstrap script and upgrades itself rather than being carried by distributions, so a recent floor costs little.
- extra_env: ClassVar = {'GHCUP_SKIP_UPDATE_CHECK': '1', 'NO_COLOR': '1'}¶
Additional environment variables to add to the current context.
Automatically applied on each
meta_package_manager.execution.CLIExecutor.run_cli()calls.
- version_cli_options: tuple[str, ...] = ('--numeric-version',)¶
Preferred over
--version, which wraps the number in a sentence and interpolates a build-time git description. This prints the bare version.
- version_regexes: tuple[str, ...] = ('^(?P<version>\\d+(?:\\.\\d+)+)',)¶
Search the bare version this option prints on its own.
$ ghcup --numeric-version 0.2.6.2
- static split_package_id(package_id)[source]¶
Split a package id back into the
<tool> <version>pair ghcup takes.Splits on the first hyphen, which is what keeps a cross-compiling GHC intact: its target triple lives in the version cell, so everything after the tool name belongs to the version.
- property installed: Iterator[Package]¶
Fetch installed packages.
--show-criteria installedfilters upstream, so the installed marker never has to be read back off the glyph column, which--raw-formatdrops anyway.$ ghcup list --raw-format --show-revisions none --show-criteria installed cabal 3.14.2.0 recommended ghc 9.6.7 recommended,base-4.18.3.0 ghcup 0.2.6.2 stray
- cli_names: tuple[str, ...] = ('ghcup',)¶
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).
- id: str = 'ghcup'¶
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.
- search(query, extended, exact)[source]¶
Fetch matching packages.
ghcup has no search command: the full listing is its catalog, and a small one, so mpm filters it itself.
Caution
Search does not support extended or exact matching.
$ ghcup list --raw-format --show-revisions none cabal 3.14.2.0 recommended ghc 9.6.7 recommended,base-4.18.3.0 ghc 9.8.1 2023-10-09
- 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.
- install(package_id, version=None)[source]¶
Install one package.
The version is already carried by the id, which is why this takes no version of its own.
$ ghcup install ghc 9.6.7
- Return type:
- remove(package_id)[source]¶
Removes a package.
Removing the version currently set neither fails nor warns: ghcup drops the symlinks and the set marker, leaving the tool simply unset.
$ ghcup rm ghc 9.6.7
- Return type:
- cleanup_cache()[source]¶
Removes things we don’t need anymore.
Confined to the download cache and the temporary directories. ghcup gc also offers switches that delete installed tools, which is not cleanup as mpm means it, and they are deliberately not passed.
$ ghcup gc --cache --tmpdirs
- Return type: