]> git.sesse.net Git - vlc/blob - bindings/python/setup.py
mkv: Remove an unneeded test.
[vlc] / bindings / python / setup.py
1 from distutils.core import setup, Extension
2 import os
3
4 # Get build variables (buildir, srcdir)
5 top_builddir = os.path.join( '..', '..' )
6 os.environ['top_builddir'] = top_builddir
7
8 # Determine the extra link args. Normally, vlc-config should take care
9 # of this and return the right path values, from a development tree or
10 # an installed version.
11 libtool=False
12 linkargs=[]
13 d=os.path.join(top_builddir, 'src', '.libs')
14 if os.path.exists(d):
15     # We are in a development tree, which was compiled with libtool
16     libtool=True
17     linkargs=[ '-L' + d ]
18 else:
19     d=os.path.join(top_builddir, 'src')
20     # We are in a development tree, which was compiled without libtool
21     if os.path.exists(d):
22         linkargs=[ '-L' + d ]
23
24 # For out-of-tree compilations
25 srcdir = '.'
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 vlc' % vlcconfig, 'r').readline().rstrip().split()
55         return cflags
56
57 def get_ldflags():
58     vlcconfig=get_vlcconfig()
59     if vlcconfig is None:
60         return [ '-lvlc' ]
61     else:
62         ldflags = []
63         if os.sys.platform == 'darwin':
64             ldflags = "-read_only_relocs warning".split()
65         ldflags.extend(os.popen('%s --libs external' % vlcconfig,
66                                 'r').readline().rstrip().split())
67         if os.sys.platform == 'darwin':
68             ldflags.append('-lstdc++')
69         if not libtool:
70             # vlc-config is broken and gives a -lvlc which
71             # does not exist if libtool is disabled.
72             ldflags.remove('-lvlc')
73         return ldflags
74
75 #source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c',
76 #                 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
77 source_files = [ 'vlc_module.c' ]
78
79 # To compile in a local vlc tree
80 vlclocal = Extension('vlc',
81                 sources = [ os.path.join( srcdir, f ) for f in source_files ],
82                 include_dirs = [ top_builddir,
83                               os.path.join( srcdir, '..', '..', 'include' ),
84                               srcdir,
85                               '/usr/win32/include' ],
86                 extra_objects = [ ],
87                 extra_compile_args = get_cflags(),
88                 extra_link_args = linkargs + get_ldflags(),
89                 )
90
91 setup (name = 'VLC Bindings',
92        version = get_vlc_version(),
93        #scripts = [ os.path.join( srcdir, 'vlcwrapper.py') ],
94        keywords = [ 'vlc', 'video' ],
95        license = "GPL", 
96        description = """VLC bindings for python.
97
98 This module provides bindings for the native libvlc API of the VLC
99 video player. Documentation can be found on the VLC wiki : 
100 http://wiki.videolan.org/index.php/ExternalAPI
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        ext_modules = [ vlclocal ])