path: root/api/examples
diff options
authorNiels de Vos <>2013-09-30 09:05:14 +0200
committerVijay Bellur <>2013-12-24 04:12:23 -0800
commitb2ee85b3e452678c330c25bf32c522090bb320fc (patch)
treeedcccb745bc4b10127eb29e1e9395a2c3cfac651 /api/examples
parent828a6eea202e9195f323a7c4b4656c73ecb34256 (diff) support dynamic loading of versioned librariesv3.4.2qa5
Currently only loads libraries by filename ending in ".so". On an installed system without development packages, the <lib>.so filenames are not available. ctypes.util.find_library() can be used to detect the files dynamically. In addition to this, also fixing some minor indention errors and package the library into the Python site-packages path. Python applications and libraries can now access libgfapi through 'from glusterfs import gfapi'. Change and review in the master branch: > Change-Id: I71e38dabd3ade5dcf24813bf2fc25cda91b571c6 > Signed-off-by: Niels de Vos <> > Reviewed-on: > Reviewed-by: Kaleb KEITHLEY <> BUG: 1005146 Change-Id: Id7665fe5140111be7bf2038454fb775c70b15993 Signed-off-by: Niels de Vos <> Reviewed-on: Tested-by: Gluster Build System <> Reviewed-by: Vijay Bellur <>
Diffstat (limited to 'api/examples')
3 files changed, 38 insertions, 5 deletions
diff --git a/api/examples/ b/api/examples/
index 6048bb1c8..cfb0d3dff 100644
--- a/api/examples/
+++ b/api/examples/
@@ -1,4 +1,6 @@
-noinst_PROGRAMS = glfsxmp
glfsxmp_SOURCES = glfsxmp.c
glfsxmp_CFLAGS = $(GLFS_CFLAGS) -Wall
-glfsxmp_LDADD = $(GLFS_LIBS) \ No newline at end of file
+glfsxmp_LDADD = $(GLFS_LIBS)
diff --git a/api/examples/ b/api/examples/
index 7d7a5bab1..f89996d9a 100755
--- a/api/examples/
+++ b/api/examples/
@@ -1,6 +1,7 @@
from ctypes import *
+from ctypes.util import find_library
import os
import sys
import time
@@ -8,9 +9,9 @@ import types
# Looks like ctypes is having trouble with dependencies, so just force them to
# load with RTLD_GLOBAL until I figure that out.
-glfs = CDLL("",RTLD_GLOBAL)
+glfs = CDLL(find_library("glusterfs"),RTLD_GLOBAL)
+xdr = CDLL(find_library("gfxdr"),RTLD_GLOBAL)
+api = CDLL(find_library("gfapi"),RTLD_GLOBAL)
# Wow, the Linux kernel folks really play nasty games with this structure. If
# you look at the man page for stat(2) and then at this definition you'll note
@@ -98,6 +99,7 @@ class File(object):
def write (self, data, flags=0):
return api.glfs_write(self.fd,data,len(data),flags)
class Dir(object):
def __init__ (self, fd):
diff --git a/api/examples/ b/api/examples/
new file mode 100644
index 000000000..44b738094
--- /dev/null
+++ b/api/examples/
@@ -0,0 +1,29 @@
+from distutils.core import setup
+# generate a for the package namespace
+fo = open('', 'w')
+fo.write('__version__ = "@PACKAGE_VERSION@"\n')
+DESC = """GlusterFS is a clustered file-system capable of scaling to
+several petabytes. It aggregates various storage bricks over Infiniband
+RDMA or TCP/IP interconnect into one large parallel network file system.
+GlusterFS is one of the most sophisticated file systems in terms of
+features and extensibility. It borrows a powerful concept called
+Translators from GNU Hurd kernel. Much of the code in GlusterFS is in
+user space and easily manageable.
+This package contains the Python interface to the libgfapi library."""
+ name='glusterfs-api',
+ version='@PACKAGE_VERSION@',
+ description='Python client library for the GlusterFS libgfapi',
+ long_description=DESC,
+ author='Gluster Community',
+ author_email='',
+ license='LGPLv3',
+ url='',
+ package_dir={'gluster':''},
+ packages=['gluster']