Recognizes if input is ogg or not.
[xiph.git] / vorbis-python / setup.py
blob43cad93912823933c6fd11b1ef075f7b0a4749ca
1 #!/usr/bin/env python
3 """Setup script for the Vorbis module distribution."""
5 import os, re, sys, string
6 from distutils.core import setup
7 from distutils.extension import Extension
9 VERSION_MAJOR = 1
10 VERSION_MINOR = 4
11 pyvorbis_version = str(VERSION_MAJOR) + '.' + str(VERSION_MINOR)
13 try:
14 import ogg._ogg
15 except ImportError:
16 print '''You must have the Ogg Python bindings
17 installed in order to build and install
18 these bindings. Import of ogg._ogg failed.'''
19 sys.exit(1)
21 def get_setup():
22 data = {}
23 r = re.compile(r'(\S+)\s*?=\s*(.+)')
25 if not os.path.isfile('Setup'):
26 print "No 'Setup' file. Perhaps you need to run the configure script."
27 sys.exit(1)
29 f = open('Setup', 'r')
31 for line in f.readlines():
32 m = r.search(line)
33 if not m:
34 print "Error in setup file:", line
35 sys.exit(1)
36 key = m.group(1)
37 val = m.group(2)
38 data[key] = val
40 return data
42 data = get_setup()
44 vorbis_include_dir = data['vorbis_include_dir']
45 vorbis_lib_dir = data['vorbis_lib_dir']
46 vorbis_libs = string.split(data['vorbis_libs'])
48 ogg_include_dir = data['ogg_include_dir']
49 ogg_lib_dir = data['ogg_lib_dir']
51 vorbismodule = Extension(name='vorbis',
52 sources=['src/vorbismodule.c',
53 'src/pyvorbisfile.c',
54 'src/pyvorbiscodec.c',
55 'src/pyvorbisinfo.c',
56 'src/vcedit.c',
57 'src/general.c'],
58 define_macros = [('VERSION', '"%s"' %
59 pyvorbis_version)],
60 include_dirs=[vorbis_include_dir,
61 ogg_include_dir],
62 library_dirs=[vorbis_lib_dir,
63 ogg_lib_dir],
64 libraries=vorbis_libs)
66 setup ( name = "pyvorbis",
67 version = pyvorbis_version,
68 description = "A wrapper for the Vorbis libraries.",
69 author = "Andrew Chatham",
70 author_email = "andrew.chatham@duke.edu",
71 url = "http://dulug.duke.edu/~andrew/pyogg",
73 packages = ['ogg'],
74 package_dir = {'ogg' : 'src'},
75 ext_package = 'ogg',
76 ext_modules = [vorbismodule])