[adios] 03/11: Changes needed for python3 - adapt pyx scripts

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Mar 1 11:42:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to tag debian/1.9.0-2
in repository adios.

commit a0d9a502f38099d42d71e175a61bd471cc56d311
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Tue Oct 27 07:25:58 2015 +0000

    Changes needed for python3 - adapt pyx scripts
    
    * Changes needed for python3 - adapt pyx scripts
    * Temporarily only build for mpich as bug in openmpi
---
 debian/changelog                    |  2 +
 debian/control                      |  3 +-
 debian/patches/mpi-workaround.patch | 48 ++++++++++++++++++
 debian/patches/py3.patch            | 97 ++++++++++++++++++++++++++++++++-----
 debian/patches/series               |  1 +
 debian/rules                        |  8 ++-
 6 files changed, 144 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 1688901..a5dee19 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 adios (1.9.0-1) UNRELEASED; urgency=medium
 
   * New upstream release
+  * Changes needed for python3 - adapt pyx scripts
+  * Temporarily only build for mpich as bug in openmpi 
 
  -- Alastair McKinstry <mckinstry at debian.org>  Fri, 14 Aug 2015 15:41:09 +0100
 
diff --git a/debian/control b/debian/control
index c4a6f50..7534f19 100644
--- a/debian/control
+++ b/debian/control
@@ -5,7 +5,8 @@ Maintainer: Alastair McKinstry <mckinstry at debian.org>
 Build-Depends: debhelper (>= 9), 
   libnetcdf-dev, 
   gfortran, libmxml-dev, 
-  mpi-default-dev, autotools-dev, cmake, libbz2-dev, zlib1g-dev, dh-autoreconf,
+  libmpich-dev,
+  autotools-dev, cmake, libbz2-dev, zlib1g-dev, dh-autoreconf,
   libibverbs-dev [ !hurd-i386 !kfreebsd-i386 !kfreebsd-amd64],
   python-dev, python-numpy, python-mpi4py, cython, dh-python,
   python3-all-dev, python3-numpy, python3-mpi4py, cython3,
diff --git a/debian/patches/mpi-workaround.patch b/debian/patches/mpi-workaround.patch
new file mode 100644
index 0000000..1e13c89
--- /dev/null
+++ b/debian/patches/mpi-workaround.patch
@@ -0,0 +1,48 @@
+Author: Alastair McKinstry <mckinstry at debian.org>
+Description: Hard-code use of mpich for the moment as openmpi doesn't
+ work; bug in OpenMPI install.
+Last-Updated: 2015-10-25
+Forwarded: not-needed
+
+Index: adios-1.9.0/wrappers/numpy/mpi.cfg
+===================================================================
+--- adios-1.9.0.orig/wrappers/numpy/mpi.cfg
++++ adios-1.9.0/wrappers/numpy/mpi.cfg
+@@ -16,6 +16,9 @@
+ # ---------------------
+ [mpi]
+ 
++mpicc		= /usr/bin/mpicc.mpich
++mpcxx		= /usr/bin/mpicxx.mpich
++
+ ## mpi_dir              = /usr
+ ## mpi_dir              = /usr/local
+ ## mpi_dir              = /usr/local/mpi
+Index: adios-1.9.0/wrappers/numpy/adios_mpi.pyx
+===================================================================
+--- adios-1.9.0.orig/wrappers/numpy/adios_mpi.pyx
++++ adios-1.9.0/wrappers/numpy/adios_mpi.pyx
+@@ -15,12 +15,12 @@ import cython
+ cimport cython
+ 
+ from libc.stdlib cimport malloc, free
+-from cpython.string cimport PyString_AsString
++from cpython.bytes cimport PyBytes_AsString
+ 
+ cdef char ** to_cstring_array(list_str):
+     cdef char **ret = <char **>malloc(len(list_str) * sizeof(char *))
+     for i in xrange(len(list_str)):
+-        ret[i] = PyString_AsString(list_str[i])
++        ret[i] = PyBytes_AsString(list_str[i])
+     return ret
+ 
+ ## ====================
+@@ -423,7 +423,7 @@ cpdef int define_attribute_byvalue (int6
+     cdef char ** pt2
+     if (val_.dtype.char == 'S'):
+         if (val_.size == 1):
+-            pt1 = PyString_AsString(val)
++            pt1 = PyBytes_AsString(val)
+             adios_define_attribute_byvalue (group,
+                                             name,
+                                             path,
diff --git a/debian/patches/py3.patch b/debian/patches/py3.patch
index 9723a72..14f088d 100644
--- a/debian/patches/py3.patch
+++ b/debian/patches/py3.patch
@@ -303,25 +303,27 @@ Index: adios-1.9.0/wrappers/numpy/Makefile
  adios.cpp:  adios.pyx
  	cython --cplus adios.pyx
  
+-adios.so:  
 +adios3.cpp:  adios.pyx
 +	cython3 --cplus -3 -o adios3.cpp adios.pyx 
 +
- adios.so:  
++adios.so:  adios.cpp
  	python setup.py build_ext -lrt
  
-+adios3.so:  
++adios3.so: adios3.cpp 
 +	python3 setup3.py build_ext -lrt
 +
  adios_mpi.cpp:  adios_mpi.pyx
  	cython --cplus adios_mpi.pyx
  
+-adios_mpi.so:  
 +adios3_mpi.cpp:  adios_mpi.pyx
 +	cython3 --cplus -3 -o adios3_mpi.cpp adios_mpi.pyx
 +
- adios_mpi.so:  
++adios_mpi.so:  adios_mpi.cpp
  	python setup_mpi.py build
  
-+adios3_mpi.so:  
++adios3_mpi.so:  adios3_mpi.cpp
 +	python3 setup3_mpi.py build
 +
  clean:
@@ -422,7 +424,15 @@ Index: adios-1.9.0/wrappers/numpy/adios_mpi.pyx
          printvar(self.vp)
          
      def __repr__(self):
-@@ -1119,8 +1120,8 @@ cdef class attr:
+@@ -1112,17 +1113,17 @@ cdef class attr:
+             self.dtype = adios2npdtype(atype, bytes)
+             if atype == DATATYPE.string_array:
+                 strlist = list()
+-                len = bytes/sizeof(p)
++                len = bytes/int(sizeof(p))
+                 for i in range(len):
+                     strlist.append((<char **>p)[i])
+                 self.value = np.array(strlist)
                  self.dtype = self.value.dtype
                      
              elif self.dtype is None:
@@ -431,8 +441,11 @@ Index: adios-1.9.0/wrappers/numpy/adios_mpi.pyx
 +                print ('Warning: No support yet: %s (type=%d, bytes=%d)' % \
 +                      (self.name, atype, bytes))
              else:
-                 len = bytes/self.dtype.itemsize
+-                len = bytes/self.dtype.itemsize
++                len = bytes/int(self.dtype.itemsize)
                  if len == 1:
+                     self.value = np.array(len, dtype=self.dtype)
+                 else:
 @@ -1473,7 +1474,7 @@ def readvar(fname, varname):
      """
      f = file(fname, comm=MPI.COMM_SELF)
@@ -454,15 +467,39 @@ Index: adios-1.9.0/wrappers/numpy/adios.pyx
  import numpy as np
  cimport numpy as np
  
+@@ -16,12 +17,12 @@ import cython
+ cimport cython
+ 
+ from libc.stdlib cimport malloc, free
+-from cpython.string cimport PyString_AsString
++from cpython.bytes cimport PyBytes_AsString
+ 
+ cdef char ** to_cstring_array(list_str):
+     cdef char **ret = <char **>malloc(len(list_str) * sizeof(char *))
+     for i in xrange(len(list_str)):
+-        ret[i] = PyString_AsString(list_str[i])
++        ret[i] = PyBytes_AsString(list_str[i])
+     return ret
+ 
+ ## ====================
 @@ -349,7 +350,7 @@ cpdef int write_double (int64_t fd_p, ch
  
  cpdef int read(int64_t fd_p, char * name, np.ndarray val):
      assert val.flags.contiguous, 'Only contiguous arrays are supported.'
 -    print "Reading ... ", val.itemsize * val.size, "(bytes)"
-+    print ("Reading ... ", val.itemsize * val.size, "(bytes)"))
++    print ("Reading ... ", val.itemsize * val.size, "(bytes)")
      return adios_read(fd_p, name, <void *> val.data, val.itemsize * val.size)
  
  cpdef int close(int64_t fd_p):
+@@ -425,7 +426,7 @@ cpdef int define_attribute_byvalue (int6
+     cdef char ** pt2
+     if (val_.dtype.char == 'S'):
+         if (val_.size == 1):
+-            pt1 = PyString_AsString(val)
++            pt1 = PyBytes_AsString(val)
+             adios_define_attribute_byvalue (group,
+                                             name,
+                                             path,
 @@ -500,24 +501,24 @@ cpdef np.dtype adios2npdtype(ADIOS_DATAT
      return ntype
  
@@ -488,7 +525,7 @@ Index: adios-1.9.0/wrappers/numpy/adios.pyx
 +    print ('%15s : %s' % ('path', f.path))
 +    print ('%15s : %d' % ('endianness', f.endianness))       
 +    print ('%15s : %d' % ('version', f.version)) 
-+    print '%15s : %lu' % ('file_size', f.file_size))
++    print ('%15s : %lu' % ('file_size', f.file_size))
  
  cdef printvar(ADIOS_VARINFO * v):
 -    print '%15s : %d' % ('varid', v.varid)
@@ -537,17 +574,53 @@ Index: adios-1.9.0/wrappers/numpy/adios.pyx
          printvar(self.vp)
          
      def __repr__(self):
-@@ -1122,8 +1123,8 @@ cdef class attr:
+@@ -1103,33 +1104,33 @@ cdef class attr:
+ 
+         cdef int64_t p
+         cdef ADIOS_DATATYPES atype
+-        cdef int bytes
++        cdef int bytess
+         cdef list strlist
+-        cdef int len
++        cdef int lenn
+         
+-        err = adios_get_attr(self.file.fp, self.name, &atype, &bytes, <void **> &p)
++        err = adios_get_attr(self.file.fp, self.name, &atype, &bytess, <void **> &p)
+ 
+         if err == 0:
+             if atype == DATATYPE.string:
+-                bytes = bytes - 1 ## Remove the NULL terminal                
+-            self.dtype = adios2npdtype(atype, bytes)
++                bytess = bytess - 1 ## Remove the NULL terminal                
++            self.dtype = adios2npdtype(atype, bytess)
+             if atype == DATATYPE.string_array:
+                 strlist = list()
+-                len = bytes/sizeof(p)
+-                for i in range(len):
++                lenn = bytess/int(sizeof(p))
++                for i in range(lenn):
+                     strlist.append((<char **>p)[i])
+                 self.value = np.array(strlist)
                  self.dtype = self.value.dtype
                      
              elif self.dtype is None:
 -                print 'Warning: No support yet: %s (type=%d, bytes=%d)' % \
 -                      (self.name, atype, bytes)
 +                print ('Warning: No support yet: %s (type=%d, bytes=%d)' % \
-+                      (self.name, atype, bytes))
++                      (self.name, atype, bytess))
              else:
-                 len = bytes/self.dtype.itemsize
-                 if len == 1:
+-                len = bytes/self.dtype.itemsize
+-                if len == 1:
+-                    self.value = np.array(len, dtype=self.dtype)
++                lenn = bytess/int(self.dtype.itemsize)
++                if lenn == 1:
++                    self.value = np.array(lenn, dtype=self.dtype)
+                 else:
+-                    self.value = np.zeros(len, dtype=self.dtype)
++                    self.value = np.zeros(lenn, dtype=self.dtype)
+                 self.value.data = <char *> p
+         else:
+             raise KeyError(name)
 @@ -1476,7 +1477,7 @@ def readvar(fname, varname):
      """
      f = file(fname, comm=MPI_COMM_SELF)
diff --git a/debian/patches/series b/debian/patches/series
index 7592741..b16c688 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -13,3 +13,4 @@ python_wrapper.patch
 autotools-fixes.patch
 multiarch_safe.patch
 py3.patch
+mpi-workaround.patch
diff --git a/debian/rules b/debian/rules
index 4c7465b..3474f34 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,6 +6,10 @@ ARCH:=$(shell dpkg --print-architecture)
 WITH_IBVERBS:= --with-ibverbs=/usr
 DO_TEST:= true
 
+MPI_IMPL:=mpich
+# MPI_IMPL should normally be $(ARCH_DEFAULT_MPI_IMPL) but due to a bug,
+# adios does not build with openmpi right now
+
 # Do tests on little-endian only for the moment;
 ifeq ($(ARCH), powerpc)
 #   DO_TEST:= false
@@ -59,8 +63,8 @@ override_dh_auto_configure:
 	dh_auto_configure --  $(WITH_LUSTRE) $(WITH_IBVERBS) --enable-shared \
 		--with-hdf5-incdir=/usr/include/hdf5/serial \
 		--with-hdf5-libdir=$(LIBDIR)/hdf5/serial \
-		--with-phdf5-incdir=/usr/include/hdf5/$(ARCH_DEFAULT_MPI_IMPL) \
-		--with-phdf5-libdir=$(LIBDIR)/hdf5/$(ARCH_DEFAULT_MPI_IMPL) \
+		--with-phdf5-incdir=/usr/include/hdf5/$(MPI_IMPL) \
+		--with-phdf5-libdir=$(LIBDIR)/hdf5/$(MPI_IMPL) \
 		--with-bzip2=/usr  --with-zlib=/usr --with-glib=/usr \
 		--prefix=/usr MPIFC=mpif77 CFLAGS='$(CFLAGS) -I$(LIBDIR)/glib-2.0/include' \
 		LIBS=' -lpthread' 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/adios.git



More information about the debian-science-commits mailing list