dmgbuild
raw JSON → 1.6.7 verified Fri May 01 auth: no python
dmgbuild is a macOS command line utility and Python library for creating disk images (.dmg files). It provides a programmatic way to build DMGs with custom backgrounds, icons, and layout. The current version is 1.6.7, with a stable maintenance release cadence. Only works on macOS.
pip install dmgbuild Common errors
error OSError: [Errno 1] Operation not permitted ↓
cause macOS sandboxing or missing permissions to create disk images.
fix
Run the script with appropriate entitlements or grant full disk access to Terminal.
error ImportError: cannot import name 'DMGObject' from 'dmgbuild' ↓
cause Old version of dmgbuild (< 1.6.0) where DMGObject was not exposed at the top level.
fix
Upgrade to version 1.6.0+: pip install --upgrade dmgbuild
error TypeError: DMGObject.__init__() takes 2 positional arguments but 3 were given ↓
cause Passing arguments incorrectly; the constructor expects (volume_name, paths) where paths is a list.
fix
Use DMGObject('Name', ['/path/to/item']) instead of DMGObject('Name', '/path/to/item')
Warnings
gotcha dmgbuild only works on macOS. Importing or running on Linux/Windows will raise an OSError about missing Apple APIs. ↓
fix Use only on macOS; for CI, use macOS runners.
breaking Version 1.6.0 dropped support for Python < 3.10. Users on Python 3.7-3.9 must stay on older versions (e.g., 1.5.2). ↓
fix Use Python >= 3.10 or pin dmgbuild to <1.6.0.
gotcha The DMGObject constructor has changed signature between versions. In newer versions, the second argument is a list of paths; in older versions it was a single path or different parameters. ↓
fix Always pass a list (even for one file): DMGObject('Volume', ['/path/to/app'])
Imports
- DMGObject
from dmgbuild import DMGObject - build_dmg wrong
dmgbuild.build_dmgcorrectfrom dmgbuild import build_dmg - settings wrong
import dmgbuild; dmgbuild.settingscorrectfrom dmgbuild import settings
Quickstart
from dmgbuild import DMGObject
# Create a DMG with a volume name and files
dmg = DMGObject('MyVolume', '/tmp/myapp.app')
dmg.build('/tmp/myapp.dmg')
print('DMG created at /tmp/myapp.dmg')