2 from setuptools import setup, Extension
4 from distutils.core import setup, Extension
6 import distutils.command.install
11 class bogus_uninstall(distutils.command.install.install):
13 Slightly bogus uninstall, just here to satisfy automake's make
14 distcheck. Do NOT actually use this to uninstall the module!
17 # I believe the word 'bogus' is operative here. When we run
18 # get_outputs() it will create subcommands, which will try to
19 # create the original 'install' object, which does not exist
20 # at this point. We need to make sure that the --prefix
21 # argument gets propagated to said object. This is not the
22 # right way to do that, but it works, for now.
23 install = self.distribution.get_command_obj('install')
24 install.prefix = self.prefix
25 install.ensure_finalized()
27 for f in self.get_outputs():
28 dirs[os.path.dirname(f)] = 1
32 print "Trying to remove file", f
37 # Gently try to remove any empty directories.
38 # This is really not guaranteed to work!!!
40 while d != self.prefix:
41 print "Trying to remove dir", d
43 if d.endswith(".egg-info"):
44 files=[os.path.join(d,f) for f in os.listdir(d)]
45 print "Trying to remove:", " ".join(files)
46 for f in files: os.unlink(f)
50 d = os.path.dirname(d)
52 def pkgconfig(*packages, **kw):
53 flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'}
54 for token in commands.getoutput("pkg-config --libs --cflags %s" % ' '.join(packages)).split():
55 kw.setdefault(flag_map.get(token[:2]), []).append(token[2:])
58 # We actually just need the header files so that we know how to unbox things
60 pygtk_includes = pkgconfig('pygtk-2.0')['include_dirs']
64 # If there is no @sphinxbase@ and friends use pkg-config
65 if '@sphinxbase@' == '' or '@sphinxbasebuild@' == '':
66 sbconf = pkgconfig('sphinxbase')
67 sb_libdirs = sbconf.get('library_dirs', [])
68 sb_includes = sbconf.get('include_dirs', [])
70 sb_includes = ['@sphinxbasebuild@/include',
71 '@sphinxbase@/include']
72 sb_libdirs = ['@sphinxbasebuild@/src/libsphinxbase/.libs']
74 libraries = ['sphinxbase', 'pocketsphinx']
75 if sys.platform == "cygwin":
76 libraries.append('iconv')
78 setup(name = 'PocketSphinx',
79 version = '@VERSION@',
80 author = 'David Huggins-Daines',
81 author_email = 'dhuggins@cs.cmu.edu',
82 description = 'Python interface to CMU PocketSphinx speech recognition',
84 url = 'http://cmusphinx.sourceforge.net',
86 Extension('pocketsphinx',
87 sources=['pocketsphinx.c'],
89 include_dirs=['@top_builddir@/include',
90 '@top_srcdir@/include',
91 '@top_srcdir@/python',
92 ] + sb_includes + pygtk_includes,
93 library_dirs=['@top_builddir@/src/libpocketsphinx/.libs'] + sb_libdirs)
95 cmdclass = {'bogus_uninstall' : bogus_uninstall}