Initial version of python-pycdio. See old pycdio repo for older history.

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
Kevin Fenzi 2019-11-26 15:24:00 -08:00
parent f54242cdae
commit 095c3a81e6
4 changed files with 426 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/pycdio-2.0.0.tar.gz

167
python-pycdio.spec Normal file
View File

@ -0,0 +1,167 @@
Name: python-pycdio
Version: 2.0.0
Release: 7%{?dist}
Summary: A Python interface to the CD Input and Control library
License: GPLv3+
URL: http://www.gnu.org/software/libcdio/
Source0: %pypi_source pycdio
# https://git.savannah.gnu.org/cgit/libcdio/pycdio.git/commit/?id=4c68c5a44f98a7cf3fa388ca66c7d312e44e78df
# https://savannah.gnu.org/bugs/?56739
Patch0: python3.patch
BuildRequires: gcc
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: libcdio-devel
BuildRequires: swig
# For tests
BuildRequires: python3-nose
%description
The pycdio (and libcdio) libraries 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.
%package -n python3-pycdio
Summary: A Python interface to the CD Input and Control library
Obsoletes: pycdio < 2.0.0-6
Provides: pycdio = %{version}-%{release}
%{?python_provide:%python_provide python3-pycdio}
%description -n python3-pycdio
The pycdio (and libcdio) libraries 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.
%prep
%autosetup -n pycdio-%{version} -p1
%build
%py3_build
%install
%py3_install
chmod 755 %{buildroot}/%{python3_sitearch}/*.so
%check
%python3 setup.py nosetests
%files -n python3-pycdio
%license COPYING
%doc README.rst ChangeLog AUTHORS NEWS THANKS
%{python3_sitearch}/__pycache__/*
%{python3_sitearch}/_pycdio*
%{python3_sitearch}/_pyiso9660*
%{python3_sitearch}/cdio.py
%{python3_sitearch}/iso9660.py
%{python3_sitearch}/pycdio.py
%{python3_sitearch}/pyiso9660.py
%{python3_sitearch}/pycdio-%{version}-py3*.egg-info/
%changelog
* Tue Nov 26 2019 Kevin Fenzi <kevin@scrye.com> - 2.0.0-7
- Review fixes: drop python3 dep, Update obsoletes, add python_provide
- Review fixes: Use pypi_source, fixed files globbing.
* Mon Nov 25 2019 Kevin Fenzi <kevin@scrye.com> - 2.0.0-6
- Rename pycdio to python3-pycdio, keeping release
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Wed Feb 07 2018 Iryna Shcherbina <ishcherb@redhat.com> - 2.0.0-2
- Update Python 2 dependency declarations to new packaging standards
(See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)
* Tue Feb 06 2018 Adrian Reber <adrian@lisas.de> - 2.0.0-1
- Updated to 2.0.0 for proper libcdio-2.0.0 support
* Thu Jan 25 2018 Adrian Reber <adrian@lisas.de> - 0.21-1
- Rebuilt for libcdio-2.0.0
- Updated to latest upstream + patches from git
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.20-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed Nov 16 2016 Adrian Reber <adrian@lisas.de> - 0.20-4
- Rebuilt for libcdio-0.94
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.20-3
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.20-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Nov 3 2015 Adam Williamson <awilliam@redhat.com> - 0.20-1
- update to latest upstream (fixes #1269003)
- clean and modernize spec a little (note: no longer EPEL5 compatible)
* Thu Jun 18 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.19-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Tue Nov 11 2014 Adrian Reber <adrian@lisas.de> - 0.19-6
- Rebuilt for libcdio-0.93
* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.19-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild
* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.19-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Mon Dec 16 2013 Adrian Reber <adrian@lisas.de> - 0.19-3
- Rebuilt for libcdio-0.92
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.19-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Mon Feb 18 2013 Adrian Reber <adrian@lisas.de> - 0.19-1
- Updated to 0.19 which actually works with libcdio-0.90
* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.18-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Tue Jan 08 2013 Adrian Reber <adrian@lisas.de> - 0.18-1
- Updated to 0.18 (for for libcdio-0.90 rebuild)
* Sat Jul 21 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.17-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
* Sat Jan 14 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.17-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
* Sun Nov 20 2011 Adrian Reber <adrian@lisas.de> - 0.17-2
- Rebuilt for libcdio-0.83
* Fri Apr 22 2011 Jay Greguske <jgregusk@redhat.com> 0.17-1
- Fix source url
* Fri Apr 22 2011 Jay Greguske <jgregusk@redhat.com> 0.17-0
- Update to 0.17
* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.16-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
* Wed Jul 21 2010 David Malcolm <dmalcolm@redhat.com> - 0.16-3
- Rebuilt for https://fedoraproject.org/wiki/Features/Python_2.7/MassRebuild
* Fri Jan 22 2010 Adrian Reber <adrian@lisas.de> - 0.16-2
- Rebuilt for libcdio-0.82
* Wed Oct 28 2009 Jay Greguske <jgregusk@redhat.com> - 0.16-1
- Updated to version 0.16
* Mon Sep 28 2009 Jay Greguske <jgregusk@redhat.com> - 0.15-4
- Off-by-one compensation in get_devices_* not needed anymore
* Tue Jul 28 2009 Jay Greguske <jgregusk@redhat.com> - 0.15-3
- Added a patch to remove unnecessary shebangs
* Mon Jul 27 2009 Jay Greguske <jgregusk@redhat.com> - 0.15-2
- Corrected the license field
* Tue Jul 21 2009 Jay Greguske <jgregusk@redhat.com> - 0.15-1
- Initial RPM release.

257
python3.patch Normal file
View File

@ -0,0 +1,257 @@
commit 4c68c5a44f98a7cf3fa388ca66c7d312e44e78df
Author: rocky <rocky@gnu.org>
Date: Sun Aug 11 16:54:52 2019 -0400
Adjust for Python 3.
See https://savannah.gnu.org/bugs/?56739
diff --git a/README.rst b/README.rst
index 5acd1a9..3643f32 100644
--- a/README.rst
+++ b/README.rst
@@ -67,11 +67,12 @@ To 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
-
+ $ 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 check
Completeness
============
diff --git a/cdio.py b/cdio.py
index 9fb7cc8..63843cd 100644
--- a/cdio.py
+++ b/cdio.py
@@ -19,8 +19,11 @@ and device-dependent properties of a CD-ROM can use this library."""
import pycdio
import _pycdio
+import sys
import types
+PYTHON2 = sys.version_info[0] <= 2
+
class DeviceException(Exception):
"""General device or driver exceptions"""
@@ -182,9 +185,10 @@ def have_driver(driver_id):
Return True if we have driver driver_id.
"""
- if isinstance(driver_id, long) or isinstance(driver_id, int):
+ if (isinstance(driver_id, int) or
+ (PYTHON2 and isinstance(driver_id, long))) :
return pycdio.have_driver(driver_id)
- elif type(driver_id)==bytes and driver_id in drivers:
+ elif type(driver_id) in (bytes, str) and driver_id in drivers:
ret = pycdio.have_driver(drivers[driver_id])
if ret == 0: return False
if ret == 1: return True
diff --git a/setup.py b/setup.py
index 86101b7..63a5cb9 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2015, 2018 Rocky Bernstein <rocky@gnu.org>
+# Copyright (C) 2015, 2018-2019 Rocky Bernstein <rocky@gnu.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,8 +20,16 @@ This gets a bit of package info from __pkginfo__.py file
"""
# Get the required package information
-from __pkginfo__ import modname, VERSION, license, short_desc, \
- web, author, author_email, classifiers
+from __pkginfo__ import (
+ modname,
+ VERSION,
+ license,
+ short_desc,
+ web,
+ author,
+ author_email,
+ classifiers,
+)
from setuptools import setup
from distutils.core import Extension
@@ -32,51 +40,57 @@ import os
import shutil
top_dir = os.path.dirname(os.path.abspath(__file__))
-README = os.path.join(top_dir, 'README.rst')
-pkg_config = os.getenv('PKG_CONFIG') or 'pkg-config'
+README = os.path.join(top_dir, "README.rst")
+pkg_config = os.getenv("PKG_CONFIG") or "pkg-config"
+
def rm_file(*paths):
- global top_dir
- toast = os.path.join(top_dir, *paths)
- try:
- os.remove(toast)
- except:
- pass
- return
+ global top_dir
+ toast = os.path.join(top_dir, *paths)
+ try:
+ os.remove(toast)
+ except:
+ pass
+ return
+
# Description in package will come from the README file.
-long_description = open(README).read() + '\n\n'
+long_description = open(README).read() + "\n\n"
# We store swig sources in ./swig, but we want the generated python
# module not to appear in that directory, but instead in the top-level
# directory where we have the other modules. I'd move *all* of the modules
# to their own directory if I knew how to do that in distutils.
-swig_opts = ['-outdir', top_dir]
+swig_opts = ["-outdir", top_dir]
+
class custom_build(build):
# Reorder build commands such that swig generated files are also copied.
- sub_commands = [('build_ext', build.has_ext_modules),
- ('build_py', build.has_pure_modules),
- ('build_clib', build.has_c_libraries),
- ('build_scripts', build.has_scripts)]
+ sub_commands = [
+ ("build_ext", build.has_ext_modules),
+ ("build_py", build.has_pure_modules),
+ ("build_clib", build.has_c_libraries),
+ ("build_scripts", build.has_scripts),
+ ]
def run(self):
# Account for API change after 0.83
- ge_2 = call([pkg_config,'--atleast-version=2.0.0','libcdio'])
+ ge_2 = call([pkg_config, "--atleast-version=2.0.0", "libcdio"])
assert ge_2 == 0, "Need at least libcdio 2.0.0 to use this"
print("libcdio version >= 2.0.0")
build.run(self)
+
# Find runtime library directories for libcdio and libiso9660 using
# pkg-config. Then create the right Extension object lists which later
# get fed into setup()'s list of ext_modules.
modules = []
-for lib_name in ('libcdio', 'libiso9660'):
- short_libname = lib_name[3:] # Strip off "lib" from name
+for lib_name in ("libcdio", "libiso9660"):
+ short_libname = lib_name[3:] # Strip off "lib" from name
# FIXME: DRY this code.
try:
- p = Popen([pkg_config, '--libs-only-L', lib_name], stdout=PIPE)
+ p = Popen([pkg_config, "--libs-only-L", lib_name], stdout=PIPE)
except:
print("** Error trying to run pkg-config. Is it installed?")
print("** If not, see http://pkg-config.freedesktop.org")
@@ -85,47 +99,56 @@ for lib_name in ('libcdio', 'libiso9660'):
if p.returncode is None:
# Strip off blanks and initial '-L'
- dirs = p.communicate()[0].split(b'-L')[1:]
+ dirs = p.communicate()[0].split(b"-L")[1:]
runtime_lib_dirs = [d.strip() for d in dirs]
else:
- print(("** Didn't the normal return code running pkg-config," +
- "on %s. got:\n\t%s" % [lib_name, p.returncode]))
+ print(
+ (
+ "** Didn't the normal return code running pkg-config,"
+ + "on %s. got:\n\t%s" % [lib_name, p.returncode]
+ )
+ )
print("** Will try to add %s anyway." % short_libname)
runtime_lib_dirs = None
library_dirs = runtime_lib_dirs
- p = Popen([pkg_config, '--cflags-only-I', lib_name], stdout=PIPE)
+ p = Popen([pkg_config, "--cflags-only-I", lib_name], stdout=PIPE)
if p.returncode is None:
- # String starts '-I' so the first entry is ''; Discard that,
- # the others we want.
- dirs = p.communicate()[0].split(b'-I')[1:]
+ # String starts '-I' so the first entry is ''; Discard that,
+ # the others we want.
+ dirs = p.communicate()[0].split(b"-I")[1:]
include_dirs = [d.strip() for d in dirs]
- p = Popen([pkg_config, '--libs-only-l', lib_name], stdout=PIPE)
+ p = Popen([pkg_config, "--libs-only-l", lib_name], stdout=PIPE)
if p.returncode is None:
- # String starts '-l' so the first entry is ''; Discard that,
- # the others we want.
- dirs = p.communicate()[0].split(b'-l')[1:]
+ # String starts '-l' so the first entry is ''; Discard that,
+ # the others we want.
+ dirs = p.communicate()[0].split(b"-l")[1:]
libraries = [d.strip().decode("utf-8") for d in dirs]
pass
- py_shortname = 'py' + short_libname
- modules.append(Extension('_' + py_shortname,
- libraries = libraries,
- swig_opts = swig_opts,
- include_dirs=include_dirs,
- library_dirs=library_dirs,
- runtime_library_dirs=runtime_lib_dirs,
- sources=['swig/%s.i' % py_shortname]))
-
-setup (author = author,
- author_email = author_email,
- classifiers = classifiers,
- cmdclass = {'build': custom_build},
- description = short_desc,
- ext_modules = modules,
- license = license,
- long_description = long_description,
- name = modname,
- py_modules = ['cdio', 'iso9660', 'pycdio', 'pyiso9660'],
- test_suite = 'nose.collector',
- url = web,
- version = VERSION,
- )
+ py_shortname = "py" + short_libname
+ modules.append(
+ Extension(
+ "_" + py_shortname,
+ libraries=libraries,
+ swig_opts=swig_opts,
+ include_dirs=include_dirs,
+ library_dirs=library_dirs,
+ runtime_library_dirs=runtime_lib_dirs,
+ sources=["swig/%s.i" % py_shortname],
+ )
+ )
+
+setup(
+ author=author,
+ author_email=author_email,
+ classifiers=classifiers,
+ cmdclass={"build": custom_build},
+ description=short_desc,
+ ext_modules=modules,
+ license=license,
+ long_description=long_description,
+ name=modname,
+ py_modules=["cdio", "iso9660", "pycdio", "pyiso9660"],
+ test_suite="nose.collector",
+ url=web,
+ version=VERSION,
+)

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (pycdio-2.0.0.tar.gz) = b73d49e143e4b5ebf5e8514d526a57f71d004b9ce4298743bb109902ee9551fa586384a236b26da9cd86284b2aa8c31fb02a324a1cebc03f2071d06fbd3e3285