pylash. Fixes #112

pull/1/head
Nedko Arnaudov 13 years ago
parent c26d5015fc
commit 309e3ca23d

1
.gitignore vendored

@ -14,3 +14,4 @@
/.lock-wscript
/build
*~
*.pyc

@ -26,6 +26,8 @@
#include "lash/lash.h"
#include "../../common/catdup.h"
//#define LOG_OUTPUT_STDOUT
#include "../../log.h"
const char * lash_protocol_string(lash_protocol_t protocol)
{
@ -58,6 +60,7 @@ void lash_args_destroy(lash_args_t * args)
lash_client_t * lash_init(const lash_args_t * args, const char * class, int client_flags, lash_protocol_t protocol)
{
log_error("ladish cannot mimic LASH server yet");
return NULL;
}

@ -0,0 +1,285 @@
# This file was automatically generated by SWIG (http://www.swig.org).
# Version 1.3.40
#
# Do not make changes to this file unless you know what you are doing--modify
# the SWIG interface file instead.
# This file is compatible with both classic and new-style classes.
from sys import version_info
if version_info >= (2,6,0):
def swig_import_helper():
from os.path import dirname
import imp
fp = None
try:
fp, pathname, description = imp.find_module('_lash', [dirname(__file__)])
except ImportError:
import _lash
return _lash
if fp is not None:
try:
_mod = imp.load_module('_lash', fp, pathname, description)
finally:
fp.close()
return _mod
_lash = swig_import_helper()
del swig_import_helper
else:
import _lash
del version_info
try:
_swig_property = property
except NameError:
pass # Python < 2.2 doesn't have 'property'.
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
if (name == "thisown"): return self.this.own(value)
if (name == "this"):
if type(value).__name__ == 'SwigPyObject':
self.__dict__[name] = value
return
method = class_type.__swig_setmethods__.get(name,None)
if method: return method(self,value)
if (not static) or hasattr(self,name):
self.__dict__[name] = value
else:
raise AttributeError("You cannot add attributes to %s" % self)
def _swig_setattr(self,class_type,name,value):
return _swig_setattr_nondynamic(self,class_type,name,value,0)
def _swig_getattr(self,class_type,name):
if (name == "thisown"): return self.this.own()
method = class_type.__swig_getmethods__.get(name,None)
if method: return method(self)
raise AttributeError(name)
def _swig_repr(self):
try: strthis = "proxy of " + self.this.__repr__()
except: strthis = ""
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
try:
_object = object
_newclass = 1
except AttributeError:
class _object : pass
_newclass = 0
LASH_DEFAULT_PORT = _lash.LASH_DEFAULT_PORT
LASH_Config_Data_Set = _lash.LASH_Config_Data_Set
LASH_Config_File = _lash.LASH_Config_File
LASH_Server_Interface = _lash.LASH_Server_Interface
LASH_No_Autoresume = _lash.LASH_No_Autoresume
LASH_Terminal = _lash.LASH_Terminal
LASH_Client_Name = _lash.LASH_Client_Name
LASH_Jack_Client_Name = _lash.LASH_Jack_Client_Name
LASH_Alsa_Client_ID = _lash.LASH_Alsa_Client_ID
LASH_Save_File = _lash.LASH_Save_File
LASH_Restore_File = _lash.LASH_Restore_File
LASH_Save_Data_Set = _lash.LASH_Save_Data_Set
LASH_Restore_Data_Set = _lash.LASH_Restore_Data_Set
LASH_Save = _lash.LASH_Save
LASH_Quit = _lash.LASH_Quit
LASH_Server_Lost = _lash.LASH_Server_Lost
LASH_Project_Add = _lash.LASH_Project_Add
LASH_Project_Remove = _lash.LASH_Project_Remove
LASH_Project_Dir = _lash.LASH_Project_Dir
LASH_Project_Name = _lash.LASH_Project_Name
LASH_Client_Add = _lash.LASH_Client_Add
LASH_Client_Remove = _lash.LASH_Client_Remove
LASH_Percentage = _lash.LASH_Percentage
LASH_PROTOCOL_MAJOR = _lash.LASH_PROTOCOL_MAJOR
LASH_PROTOCOL_MINOR = _lash.LASH_PROTOCOL_MINOR
LASH_PROTOCOL_MAJOR_MASK = _lash.LASH_PROTOCOL_MAJOR_MASK
LASH_PROTOCOL_MINOR_MASK = _lash.LASH_PROTOCOL_MINOR_MASK
def lash_protocol_string(*args):
return _lash.lash_protocol_string(*args)
lash_protocol_string = _lash.lash_protocol_string
def lash_extract_args(*args):
return _lash.lash_extract_args(*args)
lash_extract_args = _lash.lash_extract_args
def lash_init(*args):
return _lash.lash_init(*args)
lash_init = _lash.lash_init
def lash_get_server_name(*args):
return _lash.lash_get_server_name(*args)
lash_get_server_name = _lash.lash_get_server_name
def lash_get_pending_event_count(*args):
return _lash.lash_get_pending_event_count(*args)
lash_get_pending_event_count = _lash.lash_get_pending_event_count
def lash_get_event(*args):
return _lash.lash_get_event(*args)
lash_get_event = _lash.lash_get_event
def lash_get_pending_config_count(*args):
return _lash.lash_get_pending_config_count(*args)
lash_get_pending_config_count = _lash.lash_get_pending_config_count
def lash_get_config(*args):
return _lash.lash_get_config(*args)
lash_get_config = _lash.lash_get_config
def lash_send_event(*args):
return _lash.lash_send_event(*args)
lash_send_event = _lash.lash_send_event
def lash_send_config(*args):
return _lash.lash_send_config(*args)
lash_send_config = _lash.lash_send_config
def lash_server_connected(*args):
return _lash.lash_server_connected(*args)
lash_server_connected = _lash.lash_server_connected
def lash_jack_client_name(*args):
return _lash.lash_jack_client_name(*args)
lash_jack_client_name = _lash.lash_jack_client_name
def lash_alsa_client_id(*args):
return _lash.lash_alsa_client_id(*args)
lash_alsa_client_id = _lash.lash_alsa_client_id
def init(*args):
return _lash.init(*args)
init = _lash.init
def lash_event_new():
return _lash.lash_event_new()
lash_event_new = _lash.lash_event_new
def lash_event_new_with_type(*args):
return _lash.lash_event_new_with_type(*args)
lash_event_new_with_type = _lash.lash_event_new_with_type
def lash_event_new_with_all(*args):
return _lash.lash_event_new_with_all(*args)
lash_event_new_with_all = _lash.lash_event_new_with_all
def lash_event_destroy(*args):
return _lash.lash_event_destroy(*args)
lash_event_destroy = _lash.lash_event_destroy
def lash_event_get_type(*args):
return _lash.lash_event_get_type(*args)
lash_event_get_type = _lash.lash_event_get_type
def lash_event_get_string(*args):
return _lash.lash_event_get_string(*args)
lash_event_get_string = _lash.lash_event_get_string
def lash_event_get_project(*args):
return _lash.lash_event_get_project(*args)
lash_event_get_project = _lash.lash_event_get_project
def lash_event_get_client_id(*args):
return _lash.lash_event_get_client_id(*args)
lash_event_get_client_id = _lash.lash_event_get_client_id
def lash_event_set_type(*args):
return _lash.lash_event_set_type(*args)
lash_event_set_type = _lash.lash_event_set_type
def lash_event_set_string(*args):
return _lash.lash_event_set_string(*args)
lash_event_set_string = _lash.lash_event_set_string
def lash_event_set_project(*args):
return _lash.lash_event_set_project(*args)
lash_event_set_project = _lash.lash_event_set_project
def lash_event_set_client_id(*args):
return _lash.lash_event_set_client_id(*args)
lash_event_set_client_id = _lash.lash_event_set_client_id
def lash_event_set_alsa_client_id(*args):
return _lash.lash_event_set_alsa_client_id(*args)
lash_event_set_alsa_client_id = _lash.lash_event_set_alsa_client_id
def lash_event_get_alsa_client_id(*args):
return _lash.lash_event_get_alsa_client_id(*args)
lash_event_get_alsa_client_id = _lash.lash_event_get_alsa_client_id
def lash_str_set_alsa_client_id(*args):
return _lash.lash_str_set_alsa_client_id(*args)
lash_str_set_alsa_client_id = _lash.lash_str_set_alsa_client_id
def lash_str_get_alsa_client_id(*args):
return _lash.lash_str_get_alsa_client_id(*args)
lash_str_get_alsa_client_id = _lash.lash_str_get_alsa_client_id
def lash_config_new():
return _lash.lash_config_new()
lash_config_new = _lash.lash_config_new
def lash_config_dup(*args):
return _lash.lash_config_dup(*args)
lash_config_dup = _lash.lash_config_dup
def lash_config_new_with_key(*args):
return _lash.lash_config_new_with_key(*args)
lash_config_new_with_key = _lash.lash_config_new_with_key
def lash_config_destroy(*args):
return _lash.lash_config_destroy(*args)
lash_config_destroy = _lash.lash_config_destroy
def lash_config_get_key(*args):
return _lash.lash_config_get_key(*args)
lash_config_get_key = _lash.lash_config_get_key
def lash_config_get_value(*args):
return _lash.lash_config_get_value(*args)
lash_config_get_value = _lash.lash_config_get_value
def lash_config_get_value_size(*args):
return _lash.lash_config_get_value_size(*args)
lash_config_get_value_size = _lash.lash_config_get_value_size
def lash_config_set_key(*args):
return _lash.lash_config_set_key(*args)
lash_config_set_key = _lash.lash_config_set_key
def lash_config_set_value(*args):
return _lash.lash_config_set_value(*args)
lash_config_set_value = _lash.lash_config_set_value
def lash_config_get_value_int(*args):
return _lash.lash_config_get_value_int(*args)
lash_config_get_value_int = _lash.lash_config_get_value_int
def lash_config_get_value_float(*args):
return _lash.lash_config_get_value_float(*args)
lash_config_get_value_float = _lash.lash_config_get_value_float
def lash_config_get_value_double(*args):
return _lash.lash_config_get_value_double(*args)
lash_config_get_value_double = _lash.lash_config_get_value_double
def lash_config_get_value_string(*args):
return _lash.lash_config_get_value_string(*args)
lash_config_get_value_string = _lash.lash_config_get_value_string
def lash_config_set_value_int(*args):
return _lash.lash_config_set_value_int(*args)
lash_config_set_value_int = _lash.lash_config_set_value_int
def lash_config_set_value_float(*args):
return _lash.lash_config_set_value_float(*args)
lash_config_set_value_float = _lash.lash_config_set_value_float
def lash_config_set_value_double(*args):
return _lash.lash_config_set_value_double(*args)
lash_config_set_value_double = _lash.lash_config_set_value_double
def lash_config_set_value_string(*args):
return _lash.lash_config_set_value_string(*args)
lash_config_set_value_string = _lash.lash_config_set_value_string

File diff suppressed because it is too large Load Diff

@ -42,6 +42,9 @@ def lash_check_events(lash_client):
# sys.argv is modified by this call
lash_client = lash.init(sys.argv, "pylash test", lash.LASH_Config_Data_Set | lash.LASH_Terminal)
if not lash_client:
print "Cannot connect to LASH server"
sys.exit(1)
print "Successfully connected to LASH server at " + lash.lash_get_server_name(lash_client)

@ -40,8 +40,10 @@ def set_options(opt):
opt.tool_options('compiler_cc')
opt.tool_options('compiler_cxx')
opt.tool_options('boost')
opt.tool_options('python')
opt.add_option('--enable-pkg-config-dbus-service-dir', action='store_true', default=False, help='force D-Bus service install dir to be one returned by pkg-config')
opt.add_option('--enable-liblash', action='store_true', default=False, help='Build LASH compatibility library')
opt.add_option('--enable-pylash', action='store_true', default=False, help='Build python bindings for LASH compatibility library')
opt.add_option('--debug', action='store_true', default=False, dest='debug', help="Build debuggable binaries")
opt.add_option('--doxygen', action='store_true', default=False, help='Enable build of doxygen documentation')
opt.add_option('--distnodeps', action='store_true', default=False, help="When creating distribution tarball, don't package git submodules")
@ -73,10 +75,41 @@ def create_service_taskgen(bld, target, opath, binary):
obj.install_path = bld.env['DBUS_SERVICES_DIR'] + os.path.sep
obj.fun = misc.subst_func
def _get_python_variables(python_exe,variables,imports=['import sys']):
program=list(imports)
program.append('')
for v in variables:
program.append("print(repr(%s))"%v)
os_env=dict(os.environ)
try:
del os_env['MACOSX_DEPLOYMENT_TARGET']
except KeyError:
pass
proc=Utils.pproc.Popen([python_exe,"-c",'\n'.join(program)],stdout=Utils.pproc.PIPE,env=os_env)
output=proc.communicate()[0].split("\n")
if proc.returncode:
if Options.options.verbose:
warn("Python program to extract python configuration variables failed:\n%s"%'\n'.join(["line %03i: %s"%(lineno+1,line)for lineno,line in enumerate(program)]))
raise RuntimeError
return_values=[]
for s in output:
s=s.strip()
if not s:
continue
if s=='None':
return_values.append(None)
elif s[0]=="'"and s[-1]=="'":
return_values.append(s[1:-1])
elif s[0].isdigit():
return_values.append(int(s))
else:break
return return_values
def configure(conf):
conf.check_tool('compiler_cc')
conf.check_tool('compiler_cxx')
conf.check_tool('boost')
conf.check_tool('python')
#conf.check_tool('ParallelDebug')
conf.check_cfg(
@ -106,7 +139,6 @@ def configure(conf):
conf.env['LIBDIR'] = os.path.join(os.path.normpath(conf.env['PREFIX']), 'lib')
conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
conf.env['BUILD_DOXYGEN_DOCS'] = Options.options.doxygen
conf.check_cfg(
@ -161,6 +193,57 @@ def configure(conf):
conf.env['BUILD_GLADISH'] = build_gui
conf.env['BUILD_LIBLASH'] = Options.options.enable_liblash
conf.env['BUILD_PYLASH'] = Options.options.enable_pylash
if conf.env['BUILD_PYLASH'] and not conf.env['BUILD_LIBLASH']:
conf.fatal("pylash build was requested but liblash was not")
conf.env['BUILD_PYLASH'] = False
if conf.env['BUILD_PYLASH']:
conf.check_python_version()
#print conf.env['PYTHONDIR']
python = conf.env['PYTHON']
#print python
pymajmin = '.'.join(conf.env['PYTHON_VERSION'].split('.')[:2])
try:
v='prefix SO SYSLIBS LDFLAGS SHLIBS LIBDIR LIBPL INCLUDEPY Py_ENABLE_SHARED MACOSX_DEPLOYMENT_TARGET'.split()
(python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET)=_get_python_variables(python,["get_config_var('%s')"%x for x in v],['from distutils.sysconfig import get_config_var'])
except RuntimeError:
conf.fatal("Python development headers not found (-v for details).")
conf.log.write("""Configuration returned from %r:
python_prefix = %r
python_SO = %r
python_SYSLIBS = %r
python_LDFLAGS = %r
python_SHLIBS = %r
python_LIBDIR = %r
python_LIBPL = %r
INCLUDEPY = %r
Py_ENABLE_SHARED = %r
MACOSX_DEPLOYMENT_TARGET = %r
"""%(python,python_prefix,python_SO,python_SYSLIBS,python_LDFLAGS,python_SHLIBS,python_LIBDIR,python_LIBPL,INCLUDEPY,Py_ENABLE_SHARED,python_MACOSX_DEPLOYMENT_TARGET))
conf.env['pyext_PATTERN'] = '%s' + python_SO
for pattern in 'python%s-config', 'python-config-%s':
python_config = conf.find_program(pattern % pymajmin, var = 'PYTHON_CONFIG')
if python_config:
includes=[]
#print conf.env['PYTHON_CONFIG']
for incstr in Utils.cmd_output("%s --includes" % (conf.env['PYTHON_CONFIG'])).strip().split():
if (incstr.startswith('-I') or incstr.startswith('/I')):
incstr = incstr[2:]
if incstr not in includes:
includes.append(incstr)
conf.log.write("Include path for Python extensions ""(found via python-config --includes): %r\n"%(includes,))
conf.env['CPPPATH_PYEXT'] = includes
conf.env['CPPPATH_PYEMBED'] = includes
break
if not python_config:
conf.log.write("Include path for Python extensions ""(found via distutils module): %r\n"%(INCLUDEPY,))
conf.env['CPPPATH_PYEXT'] = [INCLUDEPY]
conf.env['CPPPATH_PYEMBED'] = [INCLUDEPY]
conf.env['BUILD_WERROR'] = not RELEASE
if conf.env['BUILD_WERROR']:
add_cflag(conf, '-Wall')
@ -218,6 +301,7 @@ def configure(conf):
display_msg(conf, 'Build gladish', yesno(conf.env['BUILD_GLADISH']))
display_msg(conf, 'Build liblash', yesno(Options.options.enable_liblash))
display_msg(conf, 'Build pylash', yesno(conf.env['BUILD_PYLASH']))
display_msg(conf, 'Treat warnings as errors', yesno(conf.env['BUILD_WERROR']))
display_msg(conf, 'Debuggable binaries', yesno(conf.env['BUILD_DEBUG']))
display_msg(conf, 'Build doxygen documentation', yesno(conf.env['BUILD_DOXYGEN_DOCS']))
@ -404,6 +488,20 @@ def build(bld):
#####################################################
# pylash
if bld.env['BUILD_PYLASH']:
pylash = bld.new_task_gen('cc', 'shlib', 'pyext')
pylash.target = '_lash'
pylash.uselib_local = 'lash'
pylash.source = []
pylash.install_path = bld.env['PYTHONDIR']
for source in [
'lash.c',
'lash_wrap.c',
]:
pylash.source.append(os.path.join("lash_compat", "pylash", source))
bld.install_files(bld.env['PYTHONDIR'], os.path.join("lash_compat", "pylash", "lash.py"))
# pkgpyexec_LTLIBRARIES = _lash.la
# INCLUDES = $(PYTHON_INCLUDES)

Loading…
Cancel
Save