Package: pycdio
Introductionpycdio is a Python interface to thelibcdio, the CD Input and
Control libraryhttp://www.gnu.org/software/libcdioYou can get the source at the same place as libcdio:ftp://ftp.gnu.org:/pub/gnu/libcdio/Thepycdioandlibcdiolibraries encapsulate CD-ROM reading and
control. Python programs wishing to be oblivious of the OS- and
device-dependent properties of a CD-ROM can use this library.Sample UsageGetting CD-ROM Drive Informationimportsysimportcdio,pycdiotry:d=cdio.Device(driver_id=pycdio.DRIVER_UNKNOWN)drive_name=d.get_device()exceptIOError:print("Problem finding a CD-ROM")sys.exit(1)ok,vendor,model,release=d.get_hwinfo()print("drive:%s, vendor:%s, model:%s, release:%s"\%(drive_name,vendor,model,release))# Show CD-Text for an audio CDcdt=d.get_cdtext()i_tracks=d.get_num_tracks()i_first_track=pycdio.get_first_track_num(d.cd)fortinrange(i_first_track,i_tracks+i_first_track):foriinrange(pycdio.MIN_CDTEXT_FIELD,pycdio.MAX_CDTEXT_FIELDS):value=cdt.get(i,t)# value can be empty but exist, compared to NULL valuesifvalueisnotNone:print("\t%s:%s"%(pycdio.cdtext_field2str(i),value))passpasspassreturnd.close()Other sample code can be found in theexampledirectory of the distribution.RequirementsA C compiler so the extension can be compiled when it is installed.libcdio (http://www.gnu.org/software/libcdio) and it’s header files installed.SWIGhttp://www.swig.orgpkg-confighttp://pkg-config.freedesktop.orgTo build on Debian (e.g. Ubuntu):$ apt-get install python-dev
$ apt-get install libcdio-dev
$ apt-get install libiso9660-dev
$ apt-get install swig pkg-config
$ pip install -e .
$ make checkSWIG ProblemsI’ve tried to make this work back to Python 2.3 or so.I’ve noticed however problems in various distutils.If you see a message like this when runningmake check:File "/home/rocky/.pyenv/versions/3.5.6/lib/python3.5/distutils/unixccompiler.py", line 207, in library_dir_option
 return "-L" + dir
TypeError: Can't convert 'bytes' object to str implicitlyCopy in a recent distutilsunixccompiler.pylike this:$ cp admin-tools/unixccompiler.py /home/rocky/.pyenv/versions/3.5.6/lib/python3.5/distutils/unixccompiler.pyThe distutils distribution says that it tries to be compatible with all Python versions from 2.3. Theunixccompiler.pyinadmin_toolsis from the Python 3.7.4 distribution.Completenesslibcdiois rather large and yet may still grow a bit.What is inpycdiois incomplete; over time it may grow to completion
depending on various factors: e.g. interest, whether others help
out.Sections oflibcdiothat are currently missing are the (SCSI) MMC
commands, and the cdparanoia library. Of the audio controls, I put in
those things that didn’t require any thought. The ISO 9660 library is
pretty complete, except filestat()information which is at present is
pretty minimal.That said, what’s in there is very usable. It contains probably more
access capabilities than what most media players that don’t use
libcdio have.The encapsulation by SWIG is done in two parts. The lower-level python
interface is called pycdio and is generated by SWIG.The more object-oriented module iscdio; it is a Python class that
uses pycdio. Although pycdio is perfectly usable on its own, it is
expected thatcdiois what most people will use. Aspycdiomore
closely models the C interface, it is conceivable (if unlikely) that
diehard libcdio C users who are very familiar with that interface
could prefer that.It is probably possible to change the SWIG in such a way to combine
these pieces. However there are the problems. First, I’m not that much
of a SWIG expert. Second it looks as though the resulting SWIG code
would be more complex. Third the separation makes translation very
straight forward to understand and maintain: first get what’s in C
into Python as a one-to-one translation. Then we implement some nice
abstraction off of that. The abstraction can be modified without
having to redo the underlying translation. (But the reverse is
generally not true: usually changes to the C-to-python translation,
pycdio, do result in small, but obvious and straightforward changes to
the abstraction layer cdio.)There is much to be done - you want to help out, please do so!Standalone documentation is missing although many of the methods,
classes and functions have some document strings. See also the
programs in the example directory.pycdio for enterpriseAvailable as part of the Tidelift Subscription.The maintainers of pycdio and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use.Learn more.Security contact informationTo report a security vulnerability, please use theTidelift security contactand Tidelift will coordinate the fix and disclosure.