]> git.sesse.net Git - vlc/blob - bindings/python/setup.py
python bindings: indicate that old python bindings are deprecated.
[vlc] / bindings / python / setup.py
1 import sys
2 from distutils.core import setup, Extension
3 import os
4 import commands
5
6 # Get build variables (buildir, srcdir)
7 top_builddir = os.path.join( '..', '..' )
8 os.environ['top_builddir'] = top_builddir
9
10 # Determine the extra link args. Normally, vlc-config should take care
11 # of this and return the right path values, from a development tree or
12 # an installed version.
13 libtool=False
14 linkargs=[]
15 d=os.path.join(top_builddir, 'src', '.libs')
16 if os.path.exists(d):
17     # We are in a development tree, which was compiled with libtool
18     libtool=True
19     linkargs=[ '-L' + d ]
20 else:
21     d=os.path.join(top_builddir, 'src')
22     # We are in a development tree, which was compiled without libtool
23     if os.path.exists(d):
24         linkargs=[ '-L' + d ]
25
26 # For out-of-tree compilations
27 srcdir = '.'
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     status, output = commands.getstatusoutput('pkg-config libvlc --exists')
37     if status == 0:
38         vlcconfig="pkg-config libvlc"
39     if vlcconfig is None:
40         print "*** Warning *** Cannot find vlc-config. Will try sane defaults."
41     elif os.sys.platform == 'win32':
42         # Win32 does not know how to invoke the shell itself.
43         vlcconfig="sh %s" % vlcconfig
44     return vlcconfig
45
46 def get_vlc_version():
47     vlcconfig=get_vlcconfig()
48     if vlcconfig is None:
49         return ""
50     else:
51         version=os.popen('%s --modversion' % vlcconfig, 'r').readline().strip()
52         return version
53
54 def get_cflags():
55     vlcconfig=get_vlcconfig()
56     if vlcconfig is None:
57         return []
58     else:
59         cflags=os.popen('%s --cflags ' % vlcconfig, 'r').readline().strip()
60         return cflags
61
62 def get_ldflags():
63     vlcconfig=get_vlcconfig()
64     if vlcconfig is None:
65         return [ '-lvlc' ]
66     else:
67         ldflags = []
68         if os.sys.platform == 'darwin':
69             ldflags = "-read_only_relocs warning".split()
70         ldflags.extend(os.popen('%s --libs ' % vlcconfig,
71                                 'r').readline().rstrip().split())
72         if os.sys.platform == 'darwin':
73             ldflags.append('-lstdc++')
74         if not '-lvlc' in ldflags:
75             # Some broken vlc-config can exist (esp. on win32). Try to
76             # workaround the problem.
77             ldflags.append('-lvlc')
78         return ldflags
79
80 # Import
81 if '--force-deprecated' in sys.argv:
82     sys.argv.remove('--force-deprecated')
83 else:
84     print """This native version of VLC bindings is now deprecated. 
85
86 Please use the new ctypes-based bindings, which can be built from the
87 bindings/python-ctypes directory of the VLC source tree, or directly
88 get the generated python module from
89 http://www.advene.org/download/python-ctypes
90
91 However, if you insist on building this deprecated version, you should
92 pass the --force-deprecated option on the setup.py command line.
93 """
94     sys.exit(1)
95
96 #source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c',
97 #                 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
98 source_files = [ 'vlc_module.c' ]
99
100 # To compile in a local vlc tree
101 vlclocal = Extension('vlc',
102                      sources = [ os.path.join( srcdir, f ) for f in source_files ],
103                      include_dirs = [ top_builddir,
104                                       srcdir ],
105                      extra_objects = [ ],
106                      extra_compile_args = get_cflags(),
107                      extra_link_args = linkargs + get_ldflags(),
108                      )
109
110 setup (name = 'python-vlc',
111        version = '1.0.0.90',
112        author='Olivier Aubert',
113        author_email='olivier.aubert@liris.cnrs.fr',
114        url='http://wiki.videolan.org/PythonBinding',
115        py_modules=['vlcwidget'],
116        keywords = [ 'vlc', 'video' ],
117        license = "GPL",
118        description = "VLC bindings for python.",
119        long_description = """VLC bindings for python.
120
121 This module provides bindings for the native libvlc API of the VLC
122 video player. Documentation can be found on the VLC wiki :
123 http://wiki.videolan.org/ExternalAPI
124
125 This module also provides a MediaControl object, which implements an
126 API inspired from the OMG Audio/Video Stream 1.0 specification.
127 Documentation can be found on the VLC wiki :
128 http://wiki.videolan.org/PythonBinding
129
130 Example session (for the MediaControl API):
131
132 import vlc
133 mc=vlc.MediaControl(['--verbose', '1'])
134 mc.playlist_add_item('movie.mpg')
135
136 # Start the movie at 2000ms
137 p=vlc.Position()
138 p.origin=vlc.RelativePosition
139 p.key=vlc.MediaTime
140 p.value=2000
141 mc.start(p)
142 # which could be abbreviated as
143 # mc.start(2000)
144 # for the default conversion from int is to make a RelativePosition in MediaTime
145
146 # Display some text during 2000ms
147 mc.display_text('Some useless information', 0, 2000)
148
149 # Pause the video
150 mc.pause(0)
151
152 # Get status information
153 mc.get_stream_information()
154        """,
155        ext_modules = [ vlclocal ])