From f191edc157fbcb945ea4f5bcabec9bc31292b95e Mon Sep 17 00:00:00 2001 From: "R. Bernstein" Date: Fri, 28 Nov 2008 13:44:56 -0500 Subject: [PATCH] Tighter module creation code, and a module name typo from cut and paste. --- .gitignore | 1 + setup.py | 42 +++++++++++++++++------------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 091b9057..a56a1305 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /build /dist /*.pyc +/pycdio.egg-info diff --git a/setup.py b/setup.py index 740ed7e4..ed0467d5 100755 --- a/setup.py +++ b/setup.py @@ -14,43 +14,35 @@ import os README = os.path.join(os.path.dirname(__file__), 'README.txt') long_description = open(README).read() + '\n\n' -# Find link args for libcdio and libiso9660 using pkg-config and add -# collect them into a list for setup's ext_modules. -libraries=[] -link_args=[] -for i, lib_name in enumerate(('libcdio', 'libiso9660',)): +# Find link args for libcdio and libiso9660 using pkg-config, create +# the right Extension for this to fit into ext_modules later. +modules = [] +for lib_name in ('libcdio', 'libiso9660'): + short_libname = lib_name[3:] # Strip off "lib" from name p = Popen(['pkg-config', '--libs', lib_name], stdout=PIPE) if p.returncode is None: - link_args.append([p.communicate()[0]]) - libraries.append(None) # Above includes libcdio + link_args = [p.communicate()[0].strip()] + lib = None # Above includes libcdio else: print ("Didn't the normal return code running pkg-config," + - "got:\n\t%s" % p.returncode) - short_libname = lib_name[3:] # Strip off "lib" from name + "on %s. got:\n\t%s" % [lib_name, p.returncode]) print "Will try to add %s anyway." % short_libname - link_args.append(None) - libraries.append(short_libname) # Strip off "lib" frame name -else: - libcdio_link_args = None - libcdio_library = ['cdio'] + link_args = None + lib = short_libname # Strip off "lib" frame name + py_shortname='py' + short_libname + modules.append(Extension('_' + py_shortname, + libraries = lib, + extra_link_args = link_args, + sources=['swig/%s.i' % py_shortname])) -# FIXME: incorporate into above loop. E.g. using modules=[] var. -pycdio_module = Extension('_pycdio', - libraries=libraries[0], - extra_link_args=link_args[0], - sources=['swig/pycdio.i']) -pyiso9660_module = Extension('_pyiso9660', - libraries=libraries[1], - extra_link_args=link_args[1], - sources=['swig/pyiso9660.i']) setup (name = 'pycdio', author = 'Rocky Bernstein', author_email = 'rocky@gnu.org', description = 'Python OO interface to libcdio (CD Input and Control library)', - ext_modules = [pycdio_module, pyiso9660_module], + ext_modules = modules, license = 'GPL', long_description = long_description, - name = 'pytracer', + name = 'pycdio', py_modules = ['pycdio'], test_suite = 'nose.collector', url = 'http://freshmeat.net/projects/libcdio/?branch_id=62870',