]> git.sesse.net Git - vlc/blobdiff - bindings/python/setup.py
libvlcpp: add some function to MediaPlayer class.
[vlc] / bindings / python / setup.py
index 00ac966d282c55d85e6db78f66883f3a6253e3da..4f6afc00d6db5cadb08e50d457f560648a015950 100644 (file)
@@ -1,15 +1,43 @@
+import sys
 from distutils.core import setup, Extension
 import os
+import commands
+
+# Get build variables (buildir, srcdir)
+top_builddir = os.path.join( '..', '..' )
+os.environ['top_builddir'] = top_builddir
+
+# Determine the extra link args. Normally, vlc-config should take care
+# of this and return the right path values, from a development tree or
+# an installed version.
+libtool=False
+linkargs=[]
+d=os.path.join(top_builddir, 'src', '.libs')
+if os.path.exists(d):
+    # We are in a development tree, which was compiled with libtool
+    libtool=True
+    linkargs=[ '-L' + d ]
+else:
+    d=os.path.join(top_builddir, 'src')
+    # We are in a development tree, which was compiled without libtool
+    if os.path.exists(d):
+        linkargs=[ '-L' + d ]
+
+# For out-of-tree compilations
+srcdir = '.'
 
 def get_vlcconfig():
     vlcconfig=None
     for n in ( 'vlc-config',
-               os.path.sep.join( ('..', '..', 'vlc-config' ))):
+               os.path.join( top_builddir, 'vlc-config' )):
         if os.path.exists(n):
             vlcconfig=n
             break
+    status, output = commands.getstatusoutput('pkg-config libvlc --exists')
+    if status == 0:
+        vlcconfig="pkg-config libvlc"
     if vlcconfig is None:
-        print "*** Warning *** Cannot find vlc-config"
+        print "*** Warning *** Cannot find vlc-config. Will try sane defaults."
     elif os.sys.platform == 'win32':
         # Win32 does not know how to invoke the shell itself.
         vlcconfig="sh %s" % vlcconfig
@@ -20,52 +48,86 @@ def get_vlc_version():
     if vlcconfig is None:
         return ""
     else:
-        version=os.popen('%s --version' % vlcconfig, 'r').readline().strip()
+        version=os.popen('%s --modversion' % vlcconfig, 'r').readline().strip()
         return version
-    
+
 def get_cflags():
     vlcconfig=get_vlcconfig()
     if vlcconfig is None:
         return []
     else:
-        cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
+        cflags=os.popen('%s --cflags ' % vlcconfig, 'r').readline().strip()
         return cflags
 
 def get_ldflags():
     vlcconfig=get_vlcconfig()
     if vlcconfig is None:
-        return []
+        return [ '-lvlc' ]
     else:
-       os.environ['top_builddir'] = '../..'
-        ldflags=os.popen('%s --libs vlc builtin' % vlcconfig, 'r').readline().rstrip().split()
+       ldflags = []
+       if os.sys.platform == 'darwin':
+           ldflags = "-read_only_relocs warning".split()
+        ldflags.extend(os.popen('%s --libs ' % vlcconfig,
+                                'r').readline().rstrip().split())
+       if os.sys.platform == 'darwin':
+           ldflags.append('-lstdc++')
+        if not '-lvlc' in ldflags:
+            # Some broken vlc-config can exist (esp. on win32). Try to
+            # workaround the problem.
+            ldflags.append('-lvlc')
         return ldflags
 
+# Import
+if '--force-deprecated' in sys.argv:
+    sys.argv.remove('--force-deprecated')
+else:
+    print """This native version of VLC bindings is now deprecated. 
+
+Please use the new ctypes-based bindings, which can be built from the
+bindings/python-ctypes directory of the VLC source tree, or directly
+get the generated python module from
+http://www.advene.org/download/python-ctypes
+
+However, if you insist on building this deprecated version, you should
+pass the --force-deprecated option on the setup.py command line.
+"""
+    sys.exit(1)
+
+#source_files = [ 'vlc_module.c', 'vlc_mediacontrol.c',
+#                 'vlc_position.c', 'vlc_instance.c', 'vlc_input.c' ]
+source_files = [ 'vlc_module.c' ]
+
 # To compile in a local vlc tree
 vlclocal = Extension('vlc',
-                sources = ['vlcglue.c',
-                           '../../src/control/init.c'],
-                include_dirs = ['../../include', '../../', '/usr/win32/include' ],
-                extra_objects = [ '../../lib/libvlc.a' ],
-                extra_compile_args = get_cflags(),
-               extra_link_args = [ '-L../..' ]  + get_ldflags(),
-                )
-
-setup (name = 'MediaControl',
-       version = get_vlc_version(),
-       scripts = [ 'vlcdebug.py' ],
+                     sources = [ os.path.join( srcdir, f ) for f in source_files ],
+                     include_dirs = [ top_builddir,
+                                      srcdir ],
+                     extra_objects = [ ],
+                     extra_compile_args = get_cflags(),
+                     extra_link_args = linkargs + get_ldflags(),
+                     )
+
+setup (name = 'python-vlc',
+       version = '1.0.0.90',
+       author='Olivier Aubert',
+       author_email='olivier.aubert@liris.cnrs.fr',
+       url='http://wiki.videolan.org/PythonBinding',
+       py_modules=['vlcwidget'],
        keywords = [ 'vlc', 'video' ],
-       license = "GPL", 
-       description = """VLC bindings for python.
+       license = "GPL",
+       description = "VLC bindings for python.",
+       long_description = """VLC bindings for python.
 
-This module provides a MediaControl object, which implements an API
-inspired from the OMG Audio/Video Stream 1.0 specification. Moreover,
-the module provides a Object type, which gives a low-level access to
-the vlc objects and their variables.
+This module provides bindings for the native libvlc API of the VLC
+video player. Documentation can be found on the VLC wiki :
+http://wiki.videolan.org/ExternalAPI
 
-Documentation can be found on the VLC wiki : 
-http://wiki.videolan.org/index.php/PythonBinding
+This module also provides a MediaControl object, which implements an
+API inspired from the OMG Audio/Video Stream 1.0 specification.
+Documentation can be found on the VLC wiki :
+http://wiki.videolan.org/PythonBinding
 
-Example session:
+Example session (for the MediaControl API):
 
 import vlc
 mc=vlc.MediaControl(['--verbose', '1'])
@@ -89,12 +151,5 @@ mc.pause(0)
 
 # Get status information
 mc.get_stream_information()
-
-# Access lowlevel objets
-o=vlc.Object(1)
-o.info()
-i=o.find_object('input')
-i.list()
-i.get('time')
        """,
        ext_modules = [ vlclocal ])