Initial import to Tizen
[profile/ivi/sphinxbase.git] / python / setup.py.in
1 try:
2     from setuptools import setup, Extension
3 except:
4     from distutils.core import setup, Extension
5
6 import distutils.command.install
7 import os
8 import sys
9
10 class bogus_uninstall(distutils.command.install.install):
11     """
12     Slightly bogus uninstall, just here to satisfy automake's make
13     distcheck.  Do NOT actually use this to uninstall the module!
14     """
15     def run(self):
16         # I believe the word 'bogus' is operative here.  When we run
17         # get_outputs() it will create subcommands, which will try to
18         # create the original 'install' object, which does not exist
19         # at this point.  We need to make sure that the --prefix
20         # argument gets propagated to said object.  This is not the
21         # right way to do that, but it works, for now.
22         install = self.distribution.get_command_obj('install')
23         install.prefix = self.prefix
24         install.ensure_finalized()
25         dirs = {}
26         for f in self.get_outputs():
27             dirs[os.path.dirname(f)] = 1
28             if os.path.isdir(f):
29                 dirs[f] = 1
30                 continue
31             print "Trying to remove file", f
32             try:
33                 os.unlink(f)
34             except:
35                 pass
36         # Gently try to remove any empty directories.
37         # This is really not guaranteed to work!!!
38         for d in dirs:
39             while d != self.prefix:
40                 print "Trying to remove dir", d
41                 try:
42                     if d.endswith(".egg-info"):
43                         files=[os.path.join(d,f) for f in os.listdir(d)]
44                         print "Trying to remove:", " ".join(files)
45                         for f in files: os.unlink(f)
46                     os.rmdir(d)
47                 except:
48                     pass
49                 d = os.path.dirname(d)
50
51 libraries = ['sphinxbase']
52 if sys.platform == "cygwin":
53       libraries.append("iconv")
54
55 setup(name = 'SphinxBase',
56       version = '@VERSION@',
57       author = 'David Huggins-Daines',
58       author_email = 'dhuggins@cs.cmu.edu',
59       description = 'Python interface to CMU Sphinx base libraries',
60       license = 'BSD',
61       url = 'http://cmusphinx.org',
62       ext_modules = [
63         Extension('sphinxbase',
64                    sources=['sphinxbase.c'],
65                    libraries=libraries,
66                    include_dirs=['@top_builddir@/include',
67                                  '@top_srcdir@/include'],
68                    library_dirs=['@top_builddir@/src/libsphinxbase/.libs'])
69         ],
70       cmdclass = {'bogus_uninstall' : bogus_uninstall}
71      )