]> git.sesse.net Git - vlc/blob - bindings/python/setup.py
python bindings: remove obsolete vlc_internal module
[vlc] / bindings / python / setup.py
1 from distutils.core import setup, Extension
2 import os
3 import commands
4
5 # Get build variables (buildir, srcdir)
6 top_builddir = os.path.join( '..', '..' )
7 os.environ['top_builddir'] = top_builddir
8
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 ]
24
25 # For out-of-tree compilations
26 srcdir = '.'
27
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
44
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
52
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
60
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         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                                       srcdir ],
84                      extra_objects = [ ],
85                      extra_compile_args = get_cflags(),
86                      extra_link_args = linkargs + get_ldflags(),
87                      )
88
89 setup (name = 'python-vlc',
90        version = '1.0.0.90',
91        author='Olivier Aubert',
92        author_email='olivier.aubert@liris.cnrs.fr',
93        url='http://wiki.videolan.org/PythonBinding',
94        py_modules=['vlcwidget'],
95        keywords = [ 'vlc', 'video' ],
96        license = "GPL",
97        description = "VLC bindings for python.",
98        long_description = """VLC bindings for python.
99
100 This module provides bindings for the native libvlc API of the VLC
101 video player. Documentation can be found on the VLC wiki :
102 http://wiki.videolan.org/ExternalAPI
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/PythonBinding
108
109 Example session (for the MediaControl API):
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        ext_modules = [ vlclocal ])