Skip to content

Commit

Permalink
Add bzip2 filter to build system
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Jun 3, 2022
1 parent f227663 commit 066b929
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
27 changes: 26 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,30 @@ def prefix(directory, files):
)


# BZIP2
bzip2_dir = "src/bzip2"
bzip2_sources = prefix(
bzip2_dir,
["blocksort.c", "huffman.c", "crctable.c", "randtable.c", "compress.c", "decompress.c", "bzlib.c"])
bzip2_depends = glob(bzip2_dir + "/*.h")
bzip2_include_dirs = [bzip2_dir]
bzip2_extra_compile_args = [
"-Wall",
"-Winline",
"-O2",
"-g",
"-D_FILE_OFFSET_BITS=64"
]

bzip2_plugin = HDF5PluginExtension(
"hdf5plugin.plugins.libh5bzip2",
sources=['src/PyTables/src/H5Zbzip2.c', 'src/H5Zbzip2_plugin.c'] + bzip2_sources,
depends=['src/PyTables/src/H5Zbzip2.h'] + bzip2_depends,
include_dirs=['src/PyTables/src/'] + bzip2_include_dirs,
define_macros=[('HAVE_BZ2_LIB', 1)],
extra_compile_args=bzip2_extra_compile_args,
)

# FCIDECOMP
fcidecomp_dir = 'src/fcidecomp/FCIDECOMP_V1.0.2/Software/FCIDECOMP_SOURCES'
extra_compile_args = ['-O3', '-ffast-math', '-std=c99', '-fopenmp']
Expand Down Expand Up @@ -778,7 +802,8 @@ def prefix(directory, files):

libraries = [snappy_lib, charls_lib, zfp_lib]

extensions = [lz4_plugin,
extensions = [bzip2_plugin,
lz4_plugin,
bithsuffle_plugin,
blosc_plugin,
fcidecomp_plugin,
Expand Down
28 changes: 28 additions & 0 deletions src/H5Zbzip2_plugin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Dynamically loaded filter plugin for HDF5 BZip2 filter.
*
*
*/

#include "H5Zbzip2.h"
#include "H5PLextern.h"

size_t bzip2_deflate(unsigned int flags, size_t cd_nelmts,
const unsigned int cd_values[], size_t nbytes,
size_t *buf_size, void **buf);


const H5Z_class_t H5Z_BZIP2[1] = {
{
H5Z_CLASS_T_VERS, /* H5Z_class_t version */
(H5Z_filter_t)(FILTER_BZIP2), /* filter_id */
1, 1, /* Encoding and decoding enabled */
"bzip2", /* comment */
NULL, /* can_apply_func */
NULL, /* set_local_func */
(H5Z_func_t)(bzip2_deflate) /* filter_func */
}
};

H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_FILTER;}
const void *H5PLget_plugin_info(void) {return H5Z_BZIP2;}

0 comments on commit 066b929

Please sign in to comment.