aout: lock output fifo later
[vlc.git] / bindings / python / setup.py
blob88e18fc3591aeebee2acdff45e422b00ba11df44
1 from distutils.core import setup, Extension
2 import os
3 import commands
5 # Get build variables (buildir, srcdir)
6 top_builddir = os.path.join( '..', '..' )
7 os.environ['top_builddir'] = top_builddir
9 # Determine the extra link args. Normally, vlc-config should take care
10 # of this and return the right path values, from a development tree or
11 # an installed version.
12 libtool=False
13 linkargs=[]
14 d=os.path.join(top_builddir, 'src', '.libs')
15 if os.path.exists(d):
16 # We are in a development tree, which was compiled with libtool
17 libtool=True
18 linkargs=[ '-L' + d ]
19 else:
20 d=os.path.join(top_builddir, 'src')
21 # We are in a development tree, which was compiled without libtool
22 if os.path.exists(d):
23 linkargs=[ '-L' + d ]
25 # For out-of-tree compilations
26 srcdir = '.'
28 def get_vlcconfig():
29 vlcconfig=None
30 for n in ( 'vlc-config',
31 os.path.join( top_builddir, 'vlc-config' )):
32 if os.path.exists(n):
33 vlcconfig=n
34 break
35 status, output = commands.getstatusoutput('pkg-config libvlc --exists')
36 if status == 0:
37 vlcconfig="pkg-config libvlc"
38 if vlcconfig is None:
39 print "*** Warning *** Cannot find vlc-config. Will try sane defaults."
40 elif os.sys.platform == 'win32':
41 # Win32 does not know how to invoke the shell itself.
42 vlcconfig="sh %s" % vlcconfig
43 return vlcconfig
45 def get_vlc_version():
46 vlcconfig=get_vlcconfig()
47 if vlcconfig is None:
48 return ""
49 else:
50 version=os.popen('%s --modversion' % vlcconfig, 'r').readline().strip()
51 return version
53 def get_cflags():
54 vlcconfig=get_vlcconfig()
55 if vlcconfig is None:
56 return []
57 else:
58 cflags=os.popen('%s --cflags ' % vlcconfig, 'r').readline().strip()
59 return cflags
61 def get_ldflags():
62 vlcconfig=get_vlcconfig()
63 if vlcconfig is None:
64 return [ '-lvlc' ]
65 else:
66 ldflags = []
67 if os.sys.platform == 'darwin':
68 ldflags = "-read_only_relocs warning".split()
69 ldflags.extend(os.popen('%s --libs ' % vlcconfig,
70 'r').readline().rstrip().split())
71 if os.sys.platform == 'darwin':
72 ldflags.append('-lstdc++')
73 if not '-lvlc' in ldflags:
74 # Some broken vlc-config can exist (esp. on win32). Try to
75 # workaround the problem.
76 ldflags.append('-lvlc')
77 return ldflags
79 #source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c',
80 # 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
81 source_files = [ 'vlc_module.c' ]
83 # To compile in a local vlc tree
84 vlclocal = Extension('vlc',
85 sources = [ os.path.join( srcdir, f ) for f in source_files ],
86 include_dirs = [ top_builddir,
87 srcdir ],
88 extra_objects = [ ],
89 extra_compile_args = get_cflags(),
90 extra_link_args = linkargs + get_ldflags(),
93 setup (name = 'python-vlc',
94 version = '1.0.0.90',
95 author='Olivier Aubert',
96 author_email='olivier.aubert@liris.cnrs.fr',
97 url='http://wiki.videolan.org/PythonBinding',
98 py_modules=['vlcwidget'],
99 keywords = [ 'vlc', 'video' ],
100 license = "GPL",
101 description = "VLC bindings for python.",
102 long_description = """VLC bindings for python.
104 This module provides bindings for the native libvlc API of the VLC
105 video player. Documentation can be found on the VLC wiki :
106 http://wiki.videolan.org/ExternalAPI
108 This module also provides a MediaControl object, which implements an
109 API inspired from the OMG Audio/Video Stream 1.0 specification.
110 Documentation can be found on the VLC wiki :
111 http://wiki.videolan.org/PythonBinding
113 Example session (for the MediaControl API):
115 import vlc
116 mc=vlc.MediaControl(['--verbose', '1'])
117 mc.playlist_add_item('movie.mpg')
119 # Start the movie at 2000ms
120 p=vlc.Position()
121 p.origin=vlc.RelativePosition
122 p.key=vlc.MediaTime
123 p.value=2000
124 mc.start(p)
125 # which could be abbreviated as
126 # mc.start(2000)
127 # for the default conversion from int is to make a RelativePosition in MediaTime
129 # Display some text during 2000ms
130 mc.display_text('Some useless information', 0, 2000)
132 # Pause the video
133 mc.pause(0)
135 # Get status information
136 mc.get_stream_information()
137 """,
138 ext_modules = [ vlclocal ])