]> git.sesse.net Git - vlc/blob - bindings/python/setup.py
Merge 0.8.5-api changes
[vlc] / bindings / python / setup.py
1 from distutils.core import setup, Extension
2 import os
3
4 def get_vlcconfig():
5     vlcconfig=None
6     for n in ( 'vlc-config',
7                os.path.sep.join( ('..', '..', 'vlc-config' ))):
8         if os.path.exists(n):
9             vlcconfig=n
10             break
11     if vlcconfig is None:
12         print "*** Warning *** Cannot find vlc-config"
13     elif os.sys.platform == 'win32':
14         # Win32 does not know how to invoke the shell itself.
15         vlcconfig="sh %s" % vlcconfig
16     return vlcconfig
17
18 def get_vlc_version():
19     vlcconfig=get_vlcconfig()
20     if vlcconfig is None:
21         return ""
22     else:
23         version=os.popen('%s --version' % vlcconfig, 'r').readline().strip()
24         return version
25     
26 def get_cflags():
27     vlcconfig=get_vlcconfig()
28     if vlcconfig is None:
29         return []
30     else:
31         cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
32         return cflags
33
34 def get_ldflags():
35     vlcconfig=get_vlcconfig()
36     if vlcconfig is None:
37         return []
38     else:
39         os.environ['top_builddir'] = '../..'
40         ldflags = []
41         if os.sys.platform == 'darwin':
42             ldflags = "-read_only_relocs warning".split()
43         ldflags.extend(os.popen('%s --libs vlc pic builtin' % vlcconfig, 'r').readline().rstrip().split())
44         if os.sys.platform == 'darwin':
45             ldflags.append('-lstdc++')
46         return ldflags
47
48 # To compile in a local vlc tree
49 vlclocal = Extension('vlc',
50                 sources = ['vlcglue.c',
51                            '../../src/control/mediacontrol_init.c'],
52                 include_dirs = ['../../include', '../../', '/usr/win32/include' ],
53                 extra_objects = [ '../../lib/libvlc_pic.a' ],
54                 extra_compile_args = get_cflags(),
55                 extra_link_args = [ '-L../..' ]  + get_ldflags(),
56                 )
57
58 setup (name = 'MediaControl',
59        version = get_vlc_version(),
60        scripts = [ 'vlcdebug.py' ],
61        keywords = [ 'vlc', 'video' ],
62        license = "GPL", 
63        description = """VLC bindings for python.
64
65 This module provides a MediaControl object, which implements an API
66 inspired from the OMG Audio/Video Stream 1.0 specification. Moreover,
67 the module provides a Object type, which gives a low-level access to
68 the vlc objects and their variables.
69
70 Documentation can be found on the VLC wiki : 
71 http://wiki.videolan.org/index.php/PythonBinding
72
73 Example session:
74
75 import vlc
76 mc=vlc.MediaControl(['--verbose', '1'])
77 mc.playlist_add_item('movie.mpg')
78
79 # Start the movie at 2000ms
80 p=vlc.Position()
81 p.origin=vlc.RelativePosition
82 p.key=vlc.MediaTime
83 p.value=2000
84 mc.start(p)
85 # which could be abbreviated as
86 # mc.start(2000)
87 # for the default conversion from int is to make a RelativePosition in MediaTime
88
89 # Display some text during 2000ms
90 mc.display_text('Some useless information', 0, 2000)
91
92 # Pause the video
93 mc.pause(0)
94
95 # Get status information
96 mc.get_stream_information()
97
98 # Access lowlevel objets
99 o=vlc.Object(1)
100 o.info()
101 i=o.find_object('input')
102 i.list()
103 i.get('time')
104        """,
105        ext_modules = [ vlclocal ])