]> git.sesse.net Git - vlc/blob - bindings/python/setup.py
Rename bindings/mediacontrol-python to bindings/python
[vlc] / bindings / python / setup.py
1 from distutils.core import setup, Extension
2 import os
3
4 # Get build variables (buildir, srcdir)
5 try:
6     top_builddir=os.environ['top_builddir']
7 except KeyError:
8     # Note: do not initialize here, so that we get
9     # a correct default value if the env. var is
10     # defined but empty
11     top_builddir=None
12 if not top_builddir:
13     top_builddir = os.path.join( '..', '..' )
14     os.environ['top_builddir'] = top_builddir
15
16 try:
17     srcdir=os.environ['srcdir']
18 except KeyError:
19     # Note: same as above
20     srcdir=None
21 if not srcdir:
22     srcdir = '.'
23
24 vlclib="-lvlc"
25 picflag=''
26
27 def get_vlcconfig():
28     vlcconfig=None
29     for n in ( 'vlc-config',
30                os.path.join( top_builddir, 'vlc-config' )):
31         if os.path.exists(n):
32             vlcconfig=n
33             break
34     if vlcconfig is None:
35         print "*** Warning *** Cannot find vlc-config"
36     elif os.sys.platform == 'win32':
37         # Win32 does not know how to invoke the shell itself.
38         vlcconfig="sh %s" % vlcconfig
39     return vlcconfig
40
41 def get_vlc_version():
42     vlcconfig=get_vlcconfig()
43     if vlcconfig is None:
44         return ""
45     else:
46         version=os.popen('%s --version' % vlcconfig, 'r').readline().strip()
47         return version
48     
49 def get_cflags():
50     vlcconfig=get_vlcconfig()
51     if vlcconfig is None:
52         return []
53     else:
54         cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
55         return cflags
56
57 def get_ldflags():
58     vlcconfig=get_vlcconfig()
59     if vlcconfig is None:
60         return []
61     else:
62         ldflags = []
63         if os.sys.platform == 'darwin':
64             ldflags = "-read_only_relocs warning".split()
65         ldflags.extend(os.popen('%s --libs vlc %s' % (vlcconfig,
66                                                               picflag), 
67                                 'r').readline().rstrip().split())
68         if os.sys.platform == 'darwin':
69             ldflags.append('-lstdc++')
70         return ldflags
71
72 #source_files = [ 'vlc_module.c', 'vlc_object.c', 'vlc_mediacontrol.c',
73 #                 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
74 source_files = [ 'vlc_module.c' ]
75
76 # To compile in a local vlc tree
77 vlclocal = Extension('vlc',
78                      sources = [ os.path.join( srcdir, f ) for f in source_files ],
79                      include_dirs = [ top_builddir,
80                                       os.path.join( srcdir, '..', '..', 'include' ),
81                                       srcdir,
82                                       '/usr/win32/include' ],
83                 extra_objects = [ vlclib ],
84                 extra_compile_args = get_cflags(),
85                 extra_link_args = [ '-L' + os.path.join(top_builddir, 'src') ]  + get_ldflags(),
86                 )
87
88 setup (name = 'VLC Bindings',
89        version = get_vlc_version(),
90        #scripts = [ os.path.join( srcdir, 'vlcwrapper.py') ],
91        keywords = [ 'vlc', 'video' ],
92        license = "GPL", 
93        description = """VLC bindings for python.
94
95 This module provides bindings for the native libvlc API of the VLC
96 video player. Documentation can be found on the VLC wiki : 
97 http://wiki.videolan.org/index.php/ExternalAPI
98
99 The module also provides a Object type, which gives a low-level access
100 to the vlc objects and their variables.
101
102 This module also provides a MediaControl object, which implements an
103 API inspired from the OMG Audio/Video Stream 1.0 specification.
104 Documentation can be found on the VLC wiki :
105 http://wiki.videolan.org/index.php/PythonBinding
106
107 Example session:
108
109 import vlc
110 mc=vlc.MediaControl(['--verbose', '1'])
111 mc.playlist_add_item('movie.mpg')
112
113 # Start the movie at 2000ms
114 p=vlc.Position()
115 p.origin=vlc.RelativePosition
116 p.key=vlc.MediaTime
117 p.value=2000
118 mc.start(p)
119 # which could be abbreviated as
120 # mc.start(2000)
121 # for the default conversion from int is to make a RelativePosition in MediaTime
122
123 # Display some text during 2000ms
124 mc.display_text('Some useless information', 0, 2000)
125
126 # Pause the video
127 mc.pause(0)
128
129 # Get status information
130 mc.get_stream_information()
131
132 # Access lowlevel objets
133 o=vlc.Object(1)
134 o.info()
135 i=o.find_object('input')
136 i.list()
137 i.get('time')
138
139        """,
140        ext_modules = [ vlclocal ])