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