summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2013-09-30 09:05:14 +0200
committerVijay Bellur <vbellur@redhat.com>2013-12-24 04:12:23 -0800
commitb2ee85b3e452678c330c25bf32c522090bb320fc (patch)
treeedcccb745bc4b10127eb29e1e9395a2c3cfac651
parent828a6eea202e9195f323a7c4b4656c73ecb34256 (diff)
gfapi.py: support dynamic loading of versioned librariesv3.4.2qa5
Currently gfapi.py 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 <ndevos@redhat.com> > Reviewed-on: http://review.gluster.org/5835 > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> BUG: 1005146 Change-Id: Id7665fe5140111be7bf2038454fb775c70b15993 Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/6581 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--.gitignore19
-rw-r--r--api/Makefile.am2
-rw-r--r--api/examples/Makefile.am6
-rwxr-xr-xapi/examples/gfapi.py8
-rw-r--r--api/examples/setup.py.in29
-rw-r--r--configure.ac2
-rw-r--r--glusterfs.spec.in25
7 files changed, 76 insertions, 15 deletions
diff --git a/.gitignore b/.gitignore
index 3056ad8c6..9a2334c49 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,18 +24,27 @@ stamp-h1
# Generated files
contrib/uuid/uuid_types.h
extras/init.d/glusterd.plist
+api/examples/__init__.py*
+api/examples/setup.py
+argp-standalone/libargp.a
+contrib/uuid/uuid_types.h
extras/init.d/glusterd-Debian
extras/init.d/glusterd-Redhat
extras/init.d/glusterd-SuSE
+extras/init.d/glusterd.plist
extras/ocf/glusterd
extras/ocf/volume
-glusterfs.spec
+extras/who-wrote-glusterfs/gitdm
glusterfs-api.pc
-libtool
-xlators/mount/fuse/utils/mount.glusterfs
-xlators/mount/fuse/utils/mount_glusterfs
-argp-standalone/libargp.a
+glusterfs.spec
glusterfsd/src/glusterfsd
+libgfchangelog.pc
libglusterfs/src/spec.lex.c
libglusterfs/src/y.tab.c
libglusterfs/src/y.tab.h
+libtool
+run-tests.sh
+ufo/.tox
+ufo/test/unit/.coverage
+xlators/mount/fuse/utils/mount.glusterfs
+xlators/mount/fuse/utils/mount_glusterfs
diff --git a/api/Makefile.am b/api/Makefile.am
index af437a64d..f0ad1ee97 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -1 +1 @@
-SUBDIRS = src
+SUBDIRS = src examples
diff --git a/api/examples/Makefile.am b/api/examples/Makefile.am
index 6048bb1c8..cfb0d3dff 100644
--- a/api/examples/Makefile.am
+++ b/api/examples/Makefile.am
@@ -1,4 +1,6 @@
-noinst_PROGRAMS = glfsxmp
+EXTRA_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)
+
+EXTRA_DIST = gfapi.py
diff --git a/api/examples/gfapi.py b/api/examples/gfapi.py
index 7d7a5bab1..f89996d9a 100755
--- a/api/examples/gfapi.py
+++ b/api/examples/gfapi.py
@@ -1,6 +1,7 @@
#!/usr/bin/python
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("libglusterfs.so",RTLD_GLOBAL)
-xdr = CDLL("libgfxdr.so",RTLD_GLOBAL)
-api = CDLL("libgfapi.so",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/setup.py.in b/api/examples/setup.py.in
new file mode 100644
index 000000000..44b738094
--- /dev/null
+++ b/api/examples/setup.py.in
@@ -0,0 +1,29 @@
+from distutils.core import setup
+
+# generate a __init__.py for the package namespace
+fo = open('__init__.py', 'w')
+fo.write('__version__ = "@PACKAGE_VERSION@"\n')
+fo.close()
+
+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."""
+
+setup(
+ name='glusterfs-api',
+ version='@PACKAGE_VERSION@',
+ description='Python client library for the GlusterFS libgfapi',
+ long_description=DESC,
+ author='Gluster Community',
+ author_email='gluster-devel@nongnu.org',
+ license='LGPLv3',
+ url='http://gluster.org/',
+ package_dir={'gluster':''},
+ packages=['gluster']
+)
diff --git a/configure.ac b/configure.ac
index 06c1ff693..10c8eb1cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -146,6 +146,8 @@ AC_CONFIG_FILES([Makefile
glusterfs-api.pc
api/Makefile
api/src/Makefile
+ api/examples/Makefile
+ api/examples/setup.py
glusterfs.spec])
AC_CANONICAL_HOST
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index 741025c42..d31f77265 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -46,6 +46,12 @@
%global _with_systemd true
%endif
+# From https://fedoraproject.org/wiki/Packaging:Python#Macros
+%if ( 0%{?rhel} && 0%{?rhel} <= 5 )
+%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
+%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+%endif
+
Summary: Cluster File System
%if ( 0%{_for_fedora_koji_builds} )
Name: glusterfs
@@ -284,6 +290,8 @@ This package provides the glusterfs server daemon.
Summary: Clustered file-system api library
Group: System Environment/Daemons
Requires: %{name} = %{version}-%{release}
+# we provide the Python package/namespace 'gluster'
+Provides: python-gluster = %{version}-%{release}
%description api
GlusterFS is a clustered file-system capable of scaling to several
@@ -294,7 +302,7 @@ 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 provides the glusterfs libgfapi library
+This package provides the glusterfs libgfapi library.
%if ( 0%{!?_without_ocf:1} )
%package resource-agents
@@ -385,9 +393,17 @@ This package provides the api include files.
%{__make} %{?_smp_mflags}
+pushd api/examples
+FLAGS="$RPM_OPT_FLAGS" %{__python} setup.py build
+popd
+
%install
%{__rm} -rf %{buildroot}
%{__make} install DESTDIR=%{buildroot}
+# install the gfapi Python library in /usr/lib/python*/site-packages
+pushd api/examples
+%{__python} setup.py install --skip-build --verbose --root %{buildroot}
+popd
# Install include directory
%{__mkdir_p} %{buildroot}%{_includedir}/glusterfs
%{__install} -p -m 0644 libglusterfs/src/*.h \
@@ -675,9 +691,7 @@ fi
%exclude %{_libdir}/*.so
%{_libdir}/libgfapi.*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/mount/api*
-%if ( 0%{?rhel} && 0%{?rhel} > 5 )
-%{python_sitelib}/gluster/__init__.p*
-%endif
+%{python_sitelib}/*
%if ( 0%{!?_without_ocf:1} )
%files resource-agents
@@ -762,6 +776,9 @@ if [ $1 -ge 1 ]; then
fi
%changelog
+* Mon Dec 23 2013 Niels de Vos <ndevos@redhat.com>
+- Package gfapi.py into the Python site-packages path (#1005146)
+
* Wed Oct 9 2013 Kaleb S. KEITHLEY <kkeithle@redhat.com>
- Sync with Fedora glusterfs.spec 3.4.1-2+