Skip to content

Commit 650af29

Browse files
Add cibuildwheel; disable BLAS & dependees unless requested (#91)
* Remove build-system dependency on ninja It leads to errors like this: ``` CMake Error at CMakeLists.txt:78 (project): Running '/private/var/folders/qr/vvplm_c12mbbptpkrzc_jcfh0000gn/T/pip-build-env-oab_3qec/overlay/bin/ninja' '--version' failed with: No such file or directory ``` ... possibly because the overlay entrypoint is not installed correctly. * Add cibuildwheel; disable BLAS & dependees unless requested - Disable building flat_l2 by default. Currently requires BLAS. - Add cibuildwheel workflow - Enable BLAS in regular CI for coverage - Rename VS_ENABLE_BLAS option - Finish removing BLAS support, probably - Use manylinux_2_28 - Set MACOSX_DEPLOYMENT_TARGET * Enable wheel upload * More CIBW_SKIP * Install ninja on mac * Forward Python variables from skbuild * Forward python arguments through superbuild * Use setuptools_scm * Enable wheel build on Windows * Fix guarding against declaring `std::vector<size_t>` many times. --------- Co-authored-by: Theodore Tsirpanis <[email protected]>
1 parent a88d0a6 commit 650af29

File tree

15 files changed

+125
-28
lines changed

15 files changed

+125
-28
lines changed

.github/workflows/build_wheels.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Build wheels
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build_wheels:
7+
name: Build wheels on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-22.04, macos-12, windows-2022]
12+
# `windows-2022, ` blocked by https://github.com/pybind/pybind11/issues/3445#issuecomment-1525500927
13+
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: 'Brew setup on macOS' # x-ref c8e49ba8f8b9ce
17+
if: ${{ startsWith(matrix.os, 'macos-') == true }}
18+
run: |
19+
set -e pipefail
20+
brew install automake pkg-config ninja
21+
22+
- name: Build wheels
23+
uses: pypa/[email protected]
24+
env:
25+
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
26+
CIBW_SKIP: "*-win32 cp27-* cp35-* cp36-* cp37-* pp* *_i686 *musllinux*"
27+
CIBW_ARCHS_MACOS: "x86_64 arm64"
28+
CIBW_BUILD_VERBOSITY: 3
29+
MACOSX_DEPLOYMENT_TARGET: "12.0"
30+
with:
31+
package-dir: "apis/python"
32+
output-dir: wheelhouse
33+
config-file: "{package}/pyproject.toml"
34+
35+
- uses: actions/upload-artifact@v3
36+
with:
37+
path: ./wheelhouse/*.whl
38+
39+
# TODO: Needs support for pulling in the root directory
40+
# build_sdist:
41+
# name: Build source distribution
42+
# runs-on: ubuntu-latest
43+
# steps:
44+
# - uses: actions/checkout@v3
45+
#
46+
# - name: Build sdist
47+
# run: pipx run build --sdist
48+
#
49+
# - uses: actions/upload-artifact@v3
50+
# with:
51+
# path: dist/*.tar.gz

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
run: sudo apt install libopenblas-dev
1818
- uses: actions/checkout@v3
1919
- name: Configure CMake
20-
run: cmake -S ./src -B ./src/build -DCMAKE_BUILD_TYPE=Debug
20+
run: cmake -S ./src -B ./src/build -DCMAKE_BUILD_TYPE=Debug -DTILEDB_VS_ENABLE_BLAS=ON
2121
- name: Build
2222
run: cmake --build ./src/build -j3
2323
- name: Run Tests

apis/python/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,19 @@ include(FetchContent)
3434

3535
find_package(TileDB REQUIRED)
3636

37+
# Currently, Scikit-build does not support FindPython, so we convert the
38+
# provided hints ourselves.
39+
# Otherwise, the extension will use system Python instead of cibuildwheel's venv
40+
if(SKBUILD)
41+
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
42+
set(Python_INCLUDE_DIR "${PYTHON_INCLUDE_DIR}")
43+
set(Python_LIBRARY "${PYTHON_LIBRARY}")
44+
endif()
45+
46+
set(Python_FIND_VIRTUALENV FIRST)
3747
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
3848
find_package(pybind11 CONFIG REQUIRED)
3949

40-
#set(VSPY_TARGET_NAME _vector_search)
4150
set(VSPY_TARGET_NAME _tiledbvspy)
4251

4352
python_add_library(${VSPY_TARGET_NAME} MODULE "src/tiledb/vector_search/module.cc" WITH_SOABI)

apis/python/pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "tiledb-vector-search"
3-
version = "0.0.1"
3+
dynamic = ["version"]
44
description = "TileDB Vector Search Python client"
55
license = { text = "MIT" }
66
readme = "./README.md"
@@ -34,8 +34,8 @@ repository = "https://github.com/TileDB-Inc/tiledb-vector-search"
3434
[build-system]
3535
requires = [
3636
"setuptools>=42", "wheel", "setuptools_scm>=6",
37-
"scikit-build>=0.13", "pybind11[global]",
38-
"cmake", "ninja"
37+
"scikit-build>=0.13", "pybind11[global]>=2.10",
38+
"cmake"
3939
]
4040
build-backend = "setuptools.build_meta"
4141

apis/python/setup.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ def get_cmake_overrides():
3434
if val:
3535
conf.append("-DUSE_MKL_CBLAS={}".format(val))
3636

37+
try:
38+
# Make sure we use pybind11 from this python environment if available,
39+
# required for windows wheels due to:
40+
# https://github.com/pybind/pybind11/issues/3445
41+
import pybind11
42+
pb11_path = pybind11.get_cmake_dir()
43+
conf.append(f"-Dpybind11_DIR={pb11_path}")
44+
except ImportError:
45+
pass
46+
3747
return conf
3848

3949

apis/python/src/tiledb/vector_search/module.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ PYBIND11_MODULE(_tiledbvspy, m) {
420420
declareStdVector<uint8_t>(m, "u8");
421421
declareStdVector<uint32_t>(m, "u32");
422422
declareStdVector<uint64_t>(m, "u64");
423-
if constexpr (!std::is_same<uint64_t, unsigned long>::value) {
423+
if constexpr (!std::is_same_v<uint64_t, size_t>) {
424424
declareStdVector<size_t>(m, "szt");
425425
}
426426

src/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ option(TILEDB_S3 "Enables S3/minio support using aws-cpp-sdk" ON)
4848
option(OVERRIDE_INSTALL_PREFIX "Ignores the setting of CMAKE_INSTALL_PREFIX and sets a default prefix" OFF)
4949
option(USE_MKL_CBLAS "Try to use mkl_cblas.h (requires additional CMake configuration)" OFF)
5050
option(TILEDB_VS_PYTHON "Build Python wrapping of C++ API" OFF)
51+
option(TILEDB_VS_ENABLE_BLAS "Build components and demos which require BLAS" OFF)
5152
option(BUILD_TESTS "Build the tests" ON)
5253

5354
set(CMAKE_CXX_STANDARD 20)
@@ -138,7 +139,9 @@ include(MultiThreading)
138139
# Interface library for BLAS
139140
# -----------------------------------------------------------------------------
140141
# Control compiler-specific flags.
141-
include(BLAS)
142+
if (TILEDBVS_ENABLE_FLAT_L2)
143+
include(BLAS)
144+
endif()
142145

143146
# @todo migrate to find_package for BLAS
144147
# find_package(BLAS REQUIRED)

src/cmake/BLAS.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ else()
5252

5353
endif()
5454

55+
target_compile_definitions(flat_blas INTERFACE TILEDB_VS_ENABLE_BLAS)

src/cmake/Superbuild.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ set(INHERITED_CMAKE_ARGS
6565
-DUSE_MKL_CBLAS=${USE_MKL_CBLAS}
6666
-DTILEDB_VS_PYTHON=${TILEDB_VS_PYTHON}
6767
-DBUILD_TESTS=${BUILD_TESTS}
68+
-DPython_FIND_REGISTRY=${Python_FIND_REGISTRY}
69+
-DPYTHON_VERSION_STRING=${PYTHON_VERSION_STRING}
70+
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
71+
-DPYTHON_LIBRARY=${PYTHON_LIBRARY}
72+
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
73+
-DPython_EXECUTABLE=${Python_EXECUTABLE}
74+
-DPython_ROOT_DIR=${Python_ROOT_DIR}
75+
-DPython_INCLUDE_DIR=${Python_INCLUDE_DIR}
76+
-DPython3_EXECUTABLE=${Python3_EXECUTABLE}
77+
-DPython3_ROOT_DIR=${Python3_ROOT_DIR}
78+
-DPython3_FIND_REGISTRY=${Python3_FIND_REGISTRY}
79+
-DPython3_INCLUDE_DIR=${Python3_INCLUDE_DIR}
80+
-Dpybind11_DIR=${pybind11_DIR}
6881
)
6982

7083
############################################################

src/include/algorithm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <execution>
4141
#include <functional>
4242
#include <future>
43+
#include <iterator>
4344
#include <thread>
4445
#include <utility>
4546
#include <vector>
@@ -198,4 +199,4 @@ void range_for_each(
198199

199200
} // namespace stdx
200201

201-
#endif // TDB_ALGORITHM_H
202+
#endif // TDB_ALGORITHM_H

0 commit comments

Comments
 (0)