Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Installing via setuptools
.. code-block:: console

$ python -m pip install -r requirements-dev.txt
$ python setup.py build_ext --inplace
$ python setup.py build --inplace

Any codec can be enabled (`=1`) or disabled (`=0`) on this build-path with the appropriate
OS environment variables `INCLUDE_LZ4`, `INCLUDE_SNAPPY`, `INCLUDE_ZLIB`, and
Expand Down Expand Up @@ -115,17 +115,15 @@ Using an environment variable:

.. code-block:: console

$ BLOSC_DIR=/usr/local (or "set BLOSC_DIR=\blosc" on Win)
$ export BLOSC_DIR (not needed on Win)
$ python setup.py build_clib
$ python setup.py build_ext --inplace
$ export USE_SYSTEM_BLOSC=1 # or "set USE_SYSTEM_BLOSC=1" on Windows
$ export Blosc_ROOT=/usr/local/customprefix # If you installed Blosc into a custom location
$ python setup.py build --inplace

Using a flag:
Using flags:

.. code-block:: console

$ python setup.py build_clib
$ python setup.py build_ext --inplace --blosc=/usr/local
$ python setup.py build --inplace -DUSE_SYSTEM_BLOSC:BOOL=YES -DBlosc_ROOT:PATH=/usr/local/customprefix


Testing
Expand Down
33 changes: 19 additions & 14 deletions blosc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# Todo: c-blosc provides a CMake package configuration file that we can build
# against if blosc is available on the system, etc.
# find_package(blosc)
# if(NOT blosc_FOUND)
set(BUILD_STATIC ON CACHE BOOL "Build a static version of the blosc library.")
set(BUILD_SHARED ON CACHE BOOL "Build a shared library version of the blosc library.")
set(BUILD_TESTS OFF CACHE BOOL "Build test programs form the blosc compression library")
set(BUILD_BENCHMARKS OFF CACHE BOOL "Build benchmark programs form the blosc compression library")
set(BLOSC_IS_SUBPROJECT OFF CACHE BOOL "Blosc is subproject")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(c-blosc)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/c-blosc/blosc")
add_library(blosc_extension MODULE blosc_extension.c)

if(USE_SYSTEM_BLOSC)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
find_package(Blosc REQUIRED)
target_include_directories(blosc_extension PRIVATE ${Blosc_INCLUDE_DIRS})
target_link_libraries(blosc_extension ${Blosc_LIBRARIES})
else()
set(BUILD_STATIC ON CACHE BOOL "Build a static version of the blosc library.")
set(BUILD_SHARED ON CACHE BOOL "Build a shared library version of the blosc library.")
set(BUILD_TESTS OFF CACHE BOOL "Build test programs form the blosc compression library")
set(BUILD_BENCHMARKS OFF CACHE BOOL "Build benchmark programs form the blosc compression library")
set(BLOSC_IS_SUBPROJECT OFF CACHE BOOL "Blosc is subproject")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(c-blosc)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/c-blosc/blosc")
target_link_libraries(blosc_extension blosc_static)
endif()



add_library(blosc_extension MODULE blosc_extension.c)
target_link_libraries(blosc_extension blosc_static)
python_extension_module(blosc_extension)

add_custom_command(
Expand Down
12 changes: 12 additions & 0 deletions cmake/FindBlosc.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
find_path(Blosc_INCLUDE_DIR blosc.h)

find_library(Blosc_LIBRARY NAMES blosc)

if (Blosc_INCLUDE_DIR AND Blosc_LIBRARY)
set(Blosc_FOUND TRUE)
set(Blosc_INCLUDE_DIRS ${Blosc_INCLUDE_DIR})
set(Blosc_LIBRARIES ${Blosc_LIBRARY})
message(STATUS "Found Blosc library: ${Blosc_LIBRARIES}")
else ()
message(STATUS "No Blosc library found. Using internal sources.")
endif ()
22 changes: 12 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@ def cmake_bool(cond):
url = 'http://github.com/blosc/python-blosc',
license = 'https://opensource.org/licenses/BSD-3-Clause',
platforms = ['any'],
cmake_args = [
'-DBLOSC_DIR:PATH=%s' % os.environ.get('BLOSC_DIR', ''),
'-DDEACTIVATE_SSE2:BOOL=%s' % cmake_bool(('DISABLE_BLOSC_SSE2' in os.environ) or (cpu_info is None) or ('flags' not in cpu_info) or ('sse2' not in cpu_info['flags'])),
'-DDEACTIVATE_AVX2:BOOL=%s' % cmake_bool(('DISABLE_BLOSC_AVX2' in os.environ) or (cpu_info is None) or ('flags' not in cpu_info) or ('avx2' not in cpu_info['flags'])),
'-DDEACTIVATE_LZ4:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_LZ4', '1'))),
# Snappy is disabled by default
'-DDEACTIVATE_SNAPPY:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_SNAPPY', '0'))),
'-DDEACTIVATE_ZLIB:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_ZLIB', '1'))),
'-DDEACTIVATE_ZSTD:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_ZSTD', '1'))),
],
cmake_args = (
['-DUSE_SYSTEM_BLOSC:BOOL=ON'] if int(os.environ.get('USE_SYSTEM_BLOSC', '0'))
else [
'-DUSE_SYSTEM_BLOSC:BOOL=OFF',
'-DDEACTIVATE_SSE2:BOOL=%s' % cmake_bool(('DISABLE_BLOSC_SSE2' in os.environ) or (cpu_info is None) or ('sse2' not in cpu_info['flags'])),
'-DDEACTIVATE_AVX2:BOOL=%s' % cmake_bool(('DISABLE_BLOSC_AVX2' in os.environ) or (cpu_info is None) or ('avx2' not in cpu_info['flags'])),
'-DDEACTIVATE_LZ4:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_LZ4', '1'))),
# Snappy is disabled by default
'-DDEACTIVATE_SNAPPY:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_SNAPPY', '0'))),
'-DDEACTIVATE_ZLIB:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_ZLIB', '1'))),
'-DDEACTIVATE_ZSTD:BOOL=%s' % cmake_bool(not int(os.environ.get('INCLUDE_ZSTD', '1'))),
]),
setup_requires=['scikit-build'],
tests_require=['numpy', 'psutil'],
packages = ['blosc'],
Expand Down