mac-alias
raw JSON → 2.2.3 verified Mon Apr 27 auth: no python
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.
pip install mac-alias Common errors
error ImportError: No module named 'mac_alias' ↓
cause Package not installed or wrong import path. Some older docs reference 'mac_alias' as 'mac_alias'.
fix
Install with 'pip install mac-alias' and import 'from mac_alias import Alias'.
error OSError: [Errno 2] No such file or directory: '/path/to/file' ↓
cause Alias.from_path() expects an existing file or folder on disk. Non-existent paths raise this error.
fix
Ensure the path exists before calling from_path().
Warnings
gotcha macOS-only: mac-alias works on macOS only. It will fail on Linux/Windows with an OSError or import errors for underlying macOS frameworks. ↓
fix Only use this library on macOS; use conditional imports or platform checks.
gotcha alias.to_path() may return None if the target no longer exists. The alias data can still be valid but resolution fails silently. ↓
fix Always check if result is None before using the path.
Imports
- Alias
from mac_alias import Alias
Quickstart
from mac_alias import Alias
# Create an Alias from a file path (requires macOS)
alias = Alias.from_path('/Applications')
# Serialize to bytes
alias_bytes = alias.to_bytes()
# Later, read alias and resolve
alias2 = Alias.from_bytes(alias_bytes)
path = alias2.to_path()
print(path)