Skip to content

Commit

Permalink
Migrated to use scikit-build-core
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Sep 26, 2023
1 parent 7292fd7 commit 1bb5923
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
cmake_minimum_required(VERSION 3.11.0)
project(python-blosc2)
find_package(PythonExtensions REQUIRED)
find_package(Cython REQUIRED)
find_package(NumPy REQUIRED)
cmake_minimum_required(VERSION 3.15...3.27)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)

find_package(Python COMPONENTS Interpreter Development.Module NumPy REQUIRED)

add_subdirectory(blosc2)

Expand Down
25 changes: 13 additions & 12 deletions blosc2/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
add_cython_target(blosc2_ext blosc2_ext.pyx)
add_library(blosc2_ext MODULE ${blosc2_ext})
find_program(CYTHON "cython")

add_custom_command(
OUTPUT blosc2_ext.c
DEPENDS blosc2_ext.pyx
VERBATIM
COMMAND "${CYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/blosc2_ext.pyx" --output-file
"${CMAKE_CURRENT_BINARY_DIR}/blosc2_ext.c")

Python_add_library(blosc2_ext MODULE "${CMAKE_CURRENT_BINARY_DIR}/blosc2_ext.c" WITH_SOABI)

if(USE_SYSTEM_BLOSC2)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
Expand All @@ -15,20 +23,13 @@ else()
set(BUILD_BENCHMARKS OFF CACHE BOOL "Build C-Blosc2 benchmarks")
set(BUILD_FUZZERS OFF CACHE BOOL "Build C-Blosc2 fuzzers")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# we want the binaries of the C-Blosc2 library to go into the wheels
# We want the binaries of the C-Blosc2 library to go into the wheels
set(BLOSC_INSTALL ON)
add_subdirectory(c-blosc2)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/c-blosc2/include")
target_link_libraries(blosc2_ext blosc2_static)
#target_link_libraries(blosc2_ext blosc2_static)
endif()

include_directories("${Python_NumPy_INCLUDE_DIRS}")

python_extension_module(blosc2_ext)

add_custom_command(
TARGET blosc2_ext POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:blosc2_ext> ${CMAKE_SOURCE_DIR}/blosc2
)

install(TARGETS blosc2_ext LIBRARY DESTINATION blosc2)
install(TARGETS blosc2_ext DESTINATION ${SKBUILD_PROJECT_NAME})
22 changes: 18 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
[build-system]
requires = ["setuptools", "scikit-build", "cython<3", "cmake", "ninja", "oldest-supported-numpy"]
requires = ["scikit-build-core", "cython", "numpy>=1.20.3", "ndindex>=1.4", "msgpack"]
build-backend = "scikit_build_core.build"

[project]
name = "blosc2"
version = "2.2.8"
description = "Python wrapper for the C-Blosc2 library"
readme = "README.rst"
authors = [{name = "Blosc Development Team", email = "[email protected]"}]
Expand All @@ -19,13 +21,25 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
requires-python = ">=3.8, <4"
dynamic = ["version", "dependencies"]
requires-python = ">=3.9, <4"
dependencies = [
"numpy>=1.20.3",
"ndindex>=1.4",
"msgpack",
]

[tool.scikit-build]
# Verbose printout when building.
cmake.verbose = true
cmake.build-type = "Release"
wheel.license-files = ["LICENSE.txt"]
backport.find-python = "3.26.1"
sdist.exclude = ["blosc2/c-blosc2"]

[project.urls]
homepage = "https://github.com/Blosc/python-blosc2"
Expand Down
18 changes: 2 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,12 @@
from skbuild import setup


def cmake_bool(cond):
return "ON" if cond else "OFF"


# Blosc version
VERSION = open("VERSION").read().strip()
# Create the version.py file
open("blosc2/version.py", "w").write(f'__version__ = "{VERSION}"\n')

def exclude_pkgconfig(cmake_manifest):
"""remove pkgconfig file from installation: gh-110."""
return list(filter(lambda name: not (name.endswith('.pc')), cmake_manifest))
return list(filter(lambda name: not (name.endswith(".pc")), cmake_manifest))


# These keywords need to be in setup()
# https://scikit-build.readthedocs.io/en/latest/usage.html#setuptools-options
setup(
version=VERSION,
packages=["blosc2"],
package_dir={"blosc2": "blosc2"},
include_package_data=True,
cmake_process_manifest_hook=exclude_pkgconfig,
install_requires=open("requirements-runtime.txt").read().split(),
)

0 comments on commit 1bb5923

Please sign in to comment.