PyObjC DiscRecording Framework
PyObjC-framework-DiscRecording provides Python wrappers for Apple's DiscRecording framework on macOS, enabling interaction with CD/DVD burning hardware and related functionalities. It is part of the larger PyObjC project, which provides access to macOS frameworks from Python. The library is actively maintained with frequent updates to align with new macOS SDK versions and Python releases, currently at version 12.1.
Warnings
- breaking PyObjC versions frequently drop support for older Python versions. PyObjC 12.0 dropped Python 3.9, and PyObjC 11.0 dropped Python 3.8. Ensure your Python environment meets the `requires_python` specification for your PyObjC version.
- breaking Starting with PyObjC 11.1, the core bridge's Automatic Reference Counting (ARC) behavior for initializer methods (those in the 'init' family) was updated to more closely align with `clang` documentation. This means `init` methods now correctly 'steal' a reference to `self` and return a new one. Code that manually manages reference counts around `init` calls might need adjustment.
- gotcha In PyObjC 10.3, there was a change affecting how `__init__` is called when a class implements its own `__new__`. While partially reverted in 10.3.1, code relying on the PyObjC-provided `__new__` (i.e., not overridden in Python) still cannot use `__init__`. If you implement `__new__` in your Python subclass of an Objective-C class, `__init__` will be called. Otherwise, it won't.
- gotcha PyObjC does not currently support Python's experimental free-threading (PEP 703), which was introduced in Python 3.13. Running PyObjC with a free-threading enabled Python 3.13 interpreter may lead to unexpected behavior or crashes.
- gotcha As of PyObjC 10.1, `os.fspath()` will not work directly with Cocoa `NSURL` or `CFURLRef` objects that do not refer to local filesystem paths, raising a `TypeError`. It only works for URLs convertible to local paths.
Install
-
pip install pyobjc-framework-discrecording
Imports
- DiscRecording
import DiscRecording
- DRDevice
from DiscRecording import DRDevice
Quickstart
import DiscRecording
import objc
def list_disc_devices():
devices = DiscRecording.DRDevice.allDevices()
if not devices:
print("No disc burning devices found.")
return
print("Available Disc Devices:")
for device in devices:
print(f" Name: {device.displayName()}")
print(f" Vendor: {device.vendorName()}")
print(f" Product: {device.productName()}")
print(f" Bus: {device.busName()}")
print(f" Write Capabilities: {device.writeCapabilities()['DRDeviceCanWriteDisc']}")
print(f" Can Burn: {device.canBurn()}")
print(" ---")
if __name__ == "__main__":
# Ensure the Objective-C runtime is initialized
# (often handled automatically in app contexts, but explicit for scripts)
list_disc_devices()