Tighter module creation code, and a module name typo from cut and paste.

This commit is contained in:
R. Bernstein
2008-11-28 13:44:56 -05:00
parent bd6ef49177
commit f191edc157
2 changed files with 18 additions and 25 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/build /build
/dist /dist
/*.pyc /*.pyc
/pycdio.egg-info

View File

@@ -14,43 +14,35 @@ import os
README = os.path.join(os.path.dirname(__file__), 'README.txt') README = os.path.join(os.path.dirname(__file__), 'README.txt')
long_description = open(README).read() + '\n\n' long_description = open(README).read() + '\n\n'
# Find link args for libcdio and libiso9660 using pkg-config and add # Find link args for libcdio and libiso9660 using pkg-config, create
# collect them into a list for setup's ext_modules. # the right Extension for this to fit into ext_modules later.
libraries=[] modules = []
link_args=[] for lib_name in ('libcdio', 'libiso9660'):
for i, lib_name in enumerate(('libcdio', 'libiso9660',)): short_libname = lib_name[3:] # Strip off "lib" from name
p = Popen(['pkg-config', '--libs', lib_name], stdout=PIPE) p = Popen(['pkg-config', '--libs', lib_name], stdout=PIPE)
if p.returncode is None: if p.returncode is None:
link_args.append([p.communicate()[0]]) link_args = [p.communicate()[0].strip()]
libraries.append(None) # Above includes libcdio lib = None # Above includes libcdio
else: else:
print ("Didn't the normal return code running pkg-config," + print ("Didn't the normal return code running pkg-config," +
"got:\n\t%s" % p.returncode) "on %s. got:\n\t%s" % [lib_name, p.returncode])
short_libname = lib_name[3:] # Strip off "lib" from name
print "Will try to add %s anyway." % short_libname print "Will try to add %s anyway." % short_libname
link_args.append(None) link_args = None
libraries.append(short_libname) # Strip off "lib" frame name lib = short_libname # Strip off "lib" frame name
else: py_shortname='py' + short_libname
libcdio_link_args = None modules.append(Extension('_' + py_shortname,
libcdio_library = ['cdio'] 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', setup (name = 'pycdio',
author = 'Rocky Bernstein', author = 'Rocky Bernstein',
author_email = 'rocky@gnu.org', author_email = 'rocky@gnu.org',
description = 'Python OO interface to libcdio (CD Input and Control library)', description = 'Python OO interface to libcdio (CD Input and Control library)',
ext_modules = [pycdio_module, pyiso9660_module], ext_modules = modules,
license = 'GPL', license = 'GPL',
long_description = long_description, long_description = long_description,
name = 'pytracer', name = 'pycdio',
py_modules = ['pycdio'], py_modules = ['pycdio'],
test_suite = 'nose.collector', test_suite = 'nose.collector',
url = 'http://freshmeat.net/projects/libcdio/?branch_id=62870', url = 'http://freshmeat.net/projects/libcdio/?branch_id=62870',