Author: Andreas Tille <tille@debian.org>
Last-Update: Wed, 29 Jun 2022 20:34:40 +0200
Description: Use Debian packaged streamvbyte library

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,6 @@ unset(SLOW5_USE_ZSTD CACHE)
 # include_directories(${PROJECT_SOURCE_DIR}/src)
 # include_directories(${PROJECT_SOURCE_DIR}/test)
 include_directories(${PROJECT_SOURCE_DIR}/include)
-include_directories(${PROJECT_SOURCE_DIR}/thirdparty/streamvbyte/include)
 
 set(slow5_ src/slow5.c)
 set(slow5_idx src/slow5_idx.c)
@@ -42,7 +41,6 @@ set(slow5_press src/slow5_press.c)
 # set(openmp_get_reads examples/random_read_openmp.c)
 # add_executable(slow5exmp ${openmp_get_reads})
 
-add_subdirectory(thirdparty/streamvbyte)
 
 option(SLOW5_LINK_STATIC "libslow5 will create a static lib" OFF) #OFF by default
 if(SLOW5_LINK_STATIC)
@@ -54,7 +52,7 @@ else()
 endif(SLOW5_LINK_STATIC)
 unset(SLOW5_LINK_STATIC CACHE)
 
-target_link_libraries(slow5 streamvbyte_slow5)
+target_link_libraries(slow5)
 
 # Build a static lib
 #add_library(slow5 STATIC ${slow5_} ${slow5_idx} ${slow5_misc} ${slow5_press})
--- a/test/Makefile
+++ b/test/Makefile
@@ -4,7 +4,7 @@ LIB			= ../lib
 CPPFLAGS	+= -I ../include/ -I $(SRC)/
 #CFLAGS		+= -g -Wall -Werror -Wpedantic -std=c99
 CFLAGS		+= -g -Wall -Werror -std=gnu99
-LDFLAGS		+= $(LIB)/libslow5.a -lm -lz
+LDFLAGS		+= $(LIB)/libslow5.a -lm -lz -lstreamvbyte
 ifeq ($(zstd),1)
 CFLAGS		+= -DSLOW5_USE_ZSTD
 LDFLAGS		+= -lzstd
--- a/src/slow5_press.c
+++ b/src/slow5_press.c
@@ -1034,7 +1034,7 @@ static ssize_t fwrite_compress_zlib(stru
 static uint8_t *ptr_compress_svb(const uint32_t *ptr, size_t count, size_t *n) {
     uint32_t length = count / sizeof *ptr;
 
-    size_t max_n = __slow5_streamvbyte_max_compressedbytes(length);
+    size_t max_n = streamvbyte_max_compressedbytes(length);
     uint8_t *out = (uint8_t *) malloc(max_n + sizeof length);
     if (!out) {
         SLOW5_MALLOC_ERROR();
@@ -1042,7 +1042,7 @@ static uint8_t *ptr_compress_svb(const u
         return NULL;
     }
 
-    *n = __slow5_streamvbyte_encode(ptr, length, out + sizeof length);
+    *n = streamvbyte_encode(ptr, length, out + sizeof length);
     memcpy(out, &length, sizeof length); /* copy original length of ptr (needed for depress) */
     *n = *n + sizeof length;
     SLOW5_LOG_DEBUG("max svb bytes=%zu\nsvb bytes=%zu\n",
@@ -1070,7 +1070,7 @@ static uint8_t *ptr_compress_svb_zd(cons
         slow5_errno = SLOW5_ERR_MEM;
         return NULL;
     }
-    __slow5_zigzag_delta_encode(in, diff, length, 0);
+    zigzag_delta_encode(in, diff, length, 0);
 
 
     SLOW5_LOG_DEBUG("orig bytes=%zu\n", count); /* TESTING */
@@ -1094,7 +1094,7 @@ static uint32_t *ptr_depress_svb(const u
     }
 
     size_t bytes_read;
-    if ((bytes_read = __slow5_streamvbyte_decode(ptr + sizeof length, out, length)) != count - sizeof length) {
+    if ((bytes_read = streamvbyte_decode(ptr + sizeof length, out, length)) != count - sizeof length) {
         SLOW5_ERROR("Expected streamvbyte_decode to read '%zu' bytes, instead read '%zu' bytes.",
                 count - sizeof length, bytes_read);
         slow5_errno = SLOW5_ERR_PRESS;
@@ -1122,7 +1122,7 @@ static int16_t *ptr_depress_svb_zd(const
         slow5_errno = SLOW5_ERR_MEM;
         return NULL;
     }
-    __slow5_zigzag_delta_decode(diff, orig, length, 0);
+    zigzag_delta_decode(diff, orig, length, 0);
 
     // int16_t *orig = (int16_t *) malloc(length * sizeof *orig);
     // for (int64_t i = 0; i < length; ++ i) {
--- a/setup.py
+++ b/setup.py
@@ -18,9 +18,9 @@ include_dirs = []
 # for the install.
 try:
     import numpy as np
-    include_dirs = ['include/', np.get_include(), 'thirdparty/streamvbyte/include']
+    include_dirs = ['include/', np.get_include() ]
 except ImportError:
-    include_dirs = ['include/', 'thirdparty/streamvbyte/include']
+    include_dirs = ['include/']
     def np(*args, ** kwargs ):
         import numpy as np
         return np(*args, ** kwargs)
@@ -38,13 +38,13 @@ except ImportError:
 
 sources=['python/pyslow5.pyx', 'src/slow5.c', 'src/slow5_press.c', 'src/slow5_misc.c', 'src/slow5_idx.c',
             'python/slow5threads.c',
-            'thirdparty/streamvbyte/src/streamvbyte_zigzag.c', 'thirdparty/streamvbyte/src/streamvbyte_decode.c', 'thirdparty/streamvbyte/src/streamvbyte_encode.c']
+            ]
 depends=['python/pyslow5.pxd', 'python/pyslow5.h',
             'python/slow5threads.h',
             'slow5/slow5.h', 'slow5/slow5_defs.h', 'slow5/slow5_error.h', 'slow5/slow5_press.h',
             'slow5/klib/khash.h', 'slow5/klib/kvec.h',
             'src/slow5_extra.h', 'src/slow5_idx.h', 'src/slow5_misc.h', 'src/klib/ksort.h',
-            'thirdparty/streamvbyte/include/streamvbyte.h', 'thirdparty/streamvbyte/include/streamvbyte_zigzag.h']
+            ]
 extra_compile_args = ['-g', '-Wall', '-O2', '-std=c99']
 # extra_compile_args = []
 # os.environ["CFLAGS"] = '-g -Wall -O2 -std=c99'
@@ -58,8 +58,8 @@ elif arch in ["x86_64"]:
     extra_compile_args.extend(['-DSTREAMVBYTE_SSSE3=1', '-mssse3'])   # WARNING: ancient x86_64 CPUs don't have SSSE3
 
 
-# include_dirs = ['include/', np.get_include(), 'thirdparty/streamvbyte/include']
-libraries = ['m', 'z']
+# include_dirs = ['include/', np.get_include() ]
+libraries = ['m', 'z', 'streamvbyte']
 library_dirs = ['.']
 
 # a nasty hack to provide option to build with zstd
