setup.py 2.95 KB
Newer Older
zorglub's avatar
zorglub committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
from distutils.core import setup, Extension
import os

def get_vlcconfig():
    vlcconfig=None
    for n in ( 'vlc-config',
               os.path.sep.join( ('..', '..', 'vlc-config' ))):
        if os.path.exists(n):
            vlcconfig=n
            break
    if vlcconfig is None:
        print "*** Warning *** Cannot find vlc-config"
    elif os.sys.platform == 'win32':
        # Win32 does not know how to invoke the shell itself.
        vlcconfig="sh %s" % vlcconfig
    return vlcconfig

18 19 20 21 22 23 24 25
def get_vlc_version():
    vlcconfig=get_vlcconfig()
    if vlcconfig is None:
        return ""
    else:
        version=os.popen('%s --version' % vlcconfig, 'r').readline().strip()
        return version
    
zorglub's avatar
zorglub committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39
def get_cflags():
    vlcconfig=get_vlcconfig()
    if vlcconfig is None:
        return []
    else:
        cflags=os.popen('%s --cflags' % vlcconfig, 'r').readline().rstrip().split()
        return cflags

def get_ldflags():
    vlcconfig=get_vlcconfig()
    if vlcconfig is None:
        return []
    else:
	os.environ['top_builddir'] = '../..'
40 41 42 43 44 45
	ldflags = []
	if os.sys.platform == 'darwin':
	    ldflags = "-read_only_relocs warning".split()
        ldflags.extend(os.popen('%s --libs vlc pic builtin' % vlcconfig, 'r').readline().rstrip().split())
	if os.sys.platform == 'darwin':
	    ldflags.append('-lstdc++')
zorglub's avatar
zorglub committed
46 47 48 49
        return ldflags

# To compile in a local vlc tree
vlclocal = Extension('vlc',
50
                sources = ['vlcglue.c',
zorglub's avatar
zorglub committed
51
                           '../../src/control/mediacontrol_init.c'],
zorglub's avatar
zorglub committed
52
                include_dirs = ['../../include', '../../', '/usr/win32/include' ],
53
                extra_objects = [ '../../lib/libvlc_pic.a' ],
zorglub's avatar
zorglub committed
54 55 56 57 58
                extra_compile_args = get_cflags(),
		extra_link_args = [ '-L../..' ]  + get_ldflags(),
                )

setup (name = 'MediaControl',
59
       version = get_vlc_version(),
zorglub's avatar
zorglub committed
60
       scripts = [ 'vlcdebug.py' ],
61 62
       keywords = [ 'vlc', 'video' ],
       license = "GPL", 
zorglub's avatar
zorglub committed
63 64 65 66 67 68 69
       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.

70 71 72
Documentation can be found on the VLC wiki : 
http://wiki.videolan.org/index.php/PythonBinding

zorglub's avatar
zorglub committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
Example session:

import vlc
mc=vlc.MediaControl(['--verbose', '1'])
mc.playlist_add_item('movie.mpg')

# Start the movie at 2000ms
p=vlc.Position()
p.origin=vlc.RelativePosition
p.key=vlc.MediaTime
p.value=2000
mc.start(p)
# which could be abbreviated as
# mc.start(2000)
# for the default conversion from int is to make a RelativePosition in MediaTime

# Display some text during 2000ms
mc.display_text('Some useless information', 0, 2000)

# Pause the video
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 ])