{"id":21547,"library":"mac-alias","title":"mac-alias","description":"Generate and parse macOS Alias records from Python. Version 2.2.3 supports Python >=3.10. Used by dmgbuild for creating macOS disk images. Stable release cadence, maintained as part of dmgbuild ecosystem.","status":"active","version":"2.2.3","language":"python","source_language":"en","source_url":"https://github.com/dmgbuild/mac_alias","tags":["macos","alias","dmg"],"install":[{"cmd":"pip install mac-alias","lang":"bash","label":"Default install"}],"dependencies":[],"imports":[{"note":"The Alias class is in the mac_alias package.","symbol":"Alias","correct":"from mac_alias import Alias"}],"quickstart":{"code":"from mac_alias import Alias\n\n# Create an Alias from a file path (requires macOS)\nalias = Alias.from_path('/Applications')\n# Serialize to bytes\nalias_bytes = alias.to_bytes()\n\n# Later, read alias and resolve\nalias2 = Alias.from_bytes(alias_bytes)\npath = alias2.to_path()\nprint(path)","lang":"python","description":"Create a macOS Alias from a file path, serialize to bytes, and resolve later."},"warnings":[{"fix":"Only use this library on macOS; use conditional imports or platform checks.","message":"macOS-only: mac-alias works on macOS only. It will fail on Linux/Windows with an OSError or import errors for underlying macOS frameworks.","severity":"gotcha","affected_versions":"all"},{"fix":"Always check if result is None before using the path.","message":"alias.to_path() may return None if the target no longer exists. The alias data can still be valid but resolution fails silently.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install with 'pip install mac-alias' and import 'from mac_alias import Alias'.","cause":"Package not installed or wrong import path. Some older docs reference 'mac_alias' as 'mac_alias'.","error":"ImportError: No module named 'mac_alias'"},{"fix":"Ensure the path exists before calling from_path().","cause":"Alias.from_path() expects an existing file or folder on disk. Non-existent paths raise this error.","error":"OSError: [Errno 2] No such file or directory: '/path/to/file'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}