Skip to content

Commit b81d14d

Browse files
committed
Init implementation
1 parent b95f0c9 commit b81d14d

File tree

8 files changed

+48
-107
lines changed

8 files changed

+48
-107
lines changed

.github/workflows/benchmark_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install dependencies
1818
run: |
1919
sudo apt update
20-
sudo apt install -y build-essential cmake libhwloc-dev
20+
sudo apt install -y build-essential cmake libtbb-dev
2121
2222
- name: Build in Release mode with benchmarks
2323
working-directory: ${{ github.workspace }}

.github/workflows/binding.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,19 @@ jobs:
3232
if: matrix.os == 'ubuntu-latest'
3333
run: |
3434
sudo apt update
35-
sudo apt install -y cmake build-essential doxygen
35+
sudo apt install -y cmake build-essential doxygen libtbb-dev
3636
3737
- name: Install system dependencies (macOS)
3838
if: matrix.os == 'macos-latest'
3939
run: |
40-
brew install cmake doxygen
40+
brew install cmake doxygen tbb
4141
4242
- name: Install system dependencies (Windows)
4343
if: matrix.os == 'windows-latest'
4444
run: |
4545
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
4646
choco install doxygen.install
47+
choco install tbb
4748
4849
- name: Upgrade pip and install build dependencies
4950
run: |

.github/workflows/cmake_examples.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ jobs:
2323
run: |
2424
if [ ${{ matrix.os }} == 'ubuntu-latest' ]; then
2525
sudo apt update
26-
sudo apt install binutils
26+
sudo apt install binutils libtbb-dev
27+
elif [ ${{ matrix.os }} == 'macos-latest' ]; then
28+
brew install tbb
2729
fi
2830
2931
- uses: actions/checkout@v4

.github/workflows/cmake_tests.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ jobs:
2222
if: matrix.os == 'ubuntu-latest'
2323
run: |
2424
sudo apt update
25-
sudo apt install -y lcov gcovr build-essential cmake libhwloc-dev
25+
sudo apt install -y lcov gcovr build-essential cmake libhwloc-dev libtbb-dev
26+
27+
- name: Install dependencies on macOS
28+
if: matrix.os == 'macos-latest'
29+
run: brew install tbb
2630

2731
- name: Install dependencies on Windows (vcpkg)
2832
if: matrix.os == 'windows-latest'
@@ -31,6 +35,7 @@ jobs:
3135
git clone https://github.com/microsoft/vcpkg.git vcpkg
3236
cd vcpkg
3337
.\bootstrap-vcpkg.bat
38+
.\vcpkg install tbb:x64-windows
3439
echo "VCPKG_ROOT=$env:GITHUB_WORKSPACE\vcpkg" >> $env:GITHUB_ENV
3540
echo "VCPKG_INSTALLED=$env:GITHUB_WORKSPACE\vcpkg\installed\x64-windows" >> $env:GITHUB_ENV
3641

.github/workflows/codeql.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ jobs:
2828
with:
2929
languages: ${{ matrix.language }}
3030

31+
- name: Install dependencies
32+
run: |
33+
sudo apt update
34+
sudo apt install -y libtbb-dev
35+
3136
- name: Build C++
3237
run: |
3338
mkdir -p build && cd build

.github/workflows/pypi.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install system dependencies
8080
run: |
8181
sudo apt update
82-
sudo apt install -y cmake build-essential doxygen
82+
sudo apt install -y cmake build-essential doxygen libtbb-dev
8383
8484
- name: Install build dependencies
8585
run: |
@@ -127,7 +127,7 @@ jobs:
127127

128128
- name: Install system dependencies
129129
run: |
130-
brew install cmake doxygen
130+
brew install cmake doxygen tbb
131131
132132
- name: Install build dependencies
133133
run: |
@@ -175,6 +175,7 @@ jobs:
175175
run: |
176176
choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System'
177177
choco install doxygen.install
178+
choco install tbb
178179
179180
- name: Install build dependencies
180181
run: |
@@ -208,7 +209,7 @@ jobs:
208209
- name: Install system dependencies
209210
run: |
210211
sudo apt update
211-
sudo apt install -y cmake build-essential doxygen
212+
sudo apt install -y cmake build-essential doxygen libtbb-dev
212213
213214
- name: Install build dependencies
214215
run: |

CMakeLists.txt

Lines changed: 25 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,8 @@ FetchContent_GetProperties(simdjson)
129129
if(NOT simdjson_POPULATED)
130130
FetchContent_MakeAvailable(simdjson)
131131
endif()
132-
# Get TBB
133-
set(TBB_TEST OFF CACHE BOOL "Disable TBB tests" FORCE)
134-
set(TBB_EXAMPLES OFF CACHE BOOL "Disable TBB examples" FORCE)
135-
set(TBB_STRICT OFF CACHE BOOL "Disable TBB strict mode" FORCE)
136-
# set(TBB_BUILD_SHARED ON CACHE BOOL "Build TBB as shared library" FORCE)
137-
# set(TBB_BUILD_TBBMALLOC OFF CACHE BOOL "Disable TBB malloc" FORCE)
138-
139-
FetchContent_Declare(
140-
tbb
141-
GIT_REPOSITORY https://github.com/uxlfoundation/oneTBB.git
142-
GIT_TAG v2022.3.0
143-
)
144-
FetchContent_MakeAvailable(tbb)
132+
# Check if the user has TBB installed
133+
find_package(TBB REQUIRED)
145134

146135
add_library(dsf STATIC ${SOURCES})
147136
target_compile_definitions(dsf PRIVATE SPDLOG_USE_STD_FORMAT)
@@ -209,29 +198,29 @@ if(BUILD_PYTHON_BINDINGS)
209198
target_include_directories(dsf_python_module
210199
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
211200

212-
if(APPLE)
213-
# Try to detect Homebrew prefix dynamically
214-
execute_process(
215-
COMMAND brew --prefix
216-
OUTPUT_VARIABLE HOMEBREW_PREFIX
217-
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
218-
if(HOMEBREW_PREFIX)
219-
set(HOMEBREW_LIB "${HOMEBREW_PREFIX}/lib")
220-
else()
221-
# Fallback to default Homebrew locations
222-
set(HOMEBREW_LIB "/opt/homebrew/lib;/usr/local/lib")
223-
endif()
224-
set_target_properties(
225-
dsf_python_module
226-
PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
227-
INSTALL_RPATH "${HOMEBREW_LIB};@loader_path"
228-
INSTALL_RPATH_USE_LINK_PATH TRUE)
229-
elseif(UNIX)
230-
set_target_properties(
231-
dsf_python_module
232-
PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
233-
INSTALL_RPATH "$ORIGIN")
234-
endif()
201+
# if(APPLE)
202+
# # Try to detect Homebrew prefix dynamically
203+
# execute_process(
204+
# COMMAND brew --prefix
205+
# OUTPUT_VARIABLE HOMEBREW_PREFIX
206+
# OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
207+
# if(HOMEBREW_PREFIX)
208+
# set(HOMEBREW_LIB "${HOMEBREW_PREFIX}/lib")
209+
# else()
210+
# # Fallback to default Homebrew locations
211+
# set(HOMEBREW_LIB "/opt/homebrew/lib;/usr/local/lib")
212+
# endif()
213+
# set_target_properties(
214+
# dsf_python_module
215+
# PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
216+
# INSTALL_RPATH "${HOMEBREW_LIB};@loader_path"
217+
# INSTALL_RPATH_USE_LINK_PATH TRUE)
218+
# elseif(UNIX)
219+
# set_target_properties(
220+
# dsf_python_module
221+
# PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
222+
# INSTALL_RPATH "$ORIGIN")
223+
# endif()
235224
endif()
236225

237226
# Tests

setup.py

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,14 @@ def build_extension(self, ext: CMakeExtension):
8484
# Add macOS-specific CMake prefix paths for Homebrew dependencies
8585
if platform.system() == "Darwin": # macOS
8686
try:
87-
tbb_prefix = subprocess.check_output(
88-
["brew", "--prefix", "tbb"], text=True
89-
).strip()
9087
fmt_prefix = subprocess.check_output(
9188
["brew", "--prefix", "fmt"], text=True
9289
).strip()
9390
spdlog_prefix = subprocess.check_output(
9491
["brew", "--prefix", "spdlog"], text=True
9592
).strip()
9693

97-
cmake_prefix_path = f"{tbb_prefix};{fmt_prefix};{spdlog_prefix}"
94+
cmake_prefix_path = f"{fmt_prefix};{spdlog_prefix}"
9895
cmake_args.append(f"-DCMAKE_PREFIX_PATH={cmake_prefix_path}")
9996
print(f"Added macOS Homebrew prefix paths: {cmake_prefix_path}")
10097

@@ -126,65 +123,6 @@ def build_extension(self, ext: CMakeExtension):
126123
cwd=build_temp,
127124
)
128125

129-
# Copy TBB shared library if it exists (Linux and macOS)
130-
if platform.system() == "Linux" or platform.system() == "Darwin":
131-
print(f"Searching for TBB shared libraries in {build_temp}...")
132-
133-
tbb_libs = []
134-
if platform.system() == "Linux":
135-
# Look for libtbb.so* recursively
136-
tbb_libs = list(build_temp.glob("**/libtbb.so*"))
137-
# Also look for libtbb_debug.so* if we are in debug mode or if that's what was built
138-
tbb_libs.extend(list(build_temp.glob("**/libtbb_debug.so*")))
139-
else: # macOS
140-
# Look for libtbb.dylib* recursively
141-
tbb_libs = list(build_temp.glob("**/libtbb*.dylib"))
142-
143-
if tbb_libs:
144-
print(f"Found TBB libraries: {tbb_libs}")
145-
for lib in tbb_libs:
146-
# We only want the real shared object, not symlinks if possible,
147-
# but copying everything matching the pattern is safer to ensure we get the versioned one.
148-
# However, we need to be careful not to overwrite if multiple matches found.
149-
# Usually we want the one that the linker linked against.
150-
# Since we set RPATH to $ORIGIN (Linux) or @loader_path (macOS), we need the library in the same dir as the extension.
151-
152-
# Avoid copying if it's a symlink pointing to something we already copied?
153-
# simpler: just copy all of them.
154-
dest = extdir / lib.name
155-
if not dest.exists():
156-
shutil.copy2(lib, dest)
157-
print(f"Copied {lib} to {dest}")
158-
else:
159-
print("Warning: No TBB shared libraries found to copy.")
160-
161-
elif platform.system() == "Windows":
162-
print(f"Searching for TBB DLLs in {build_temp}...")
163-
# Look for tbb*.dll recursively
164-
tbb_dlls = list(build_temp.glob("**/tbb*.dll"))
165-
166-
if tbb_dlls:
167-
print(f"Found TBB DLLs: {tbb_dlls}")
168-
# We want to copy them to the 'dsf' package directory so we can load them in __init__.py
169-
# extdir is where dsf_cpp.pyd is (site-packages root usually)
170-
# We want site-packages/dsf/
171-
172-
# self.build_lib is usually the root of the build (e.g. build/lib.win...)
173-
# So we can construct the path to dsf package
174-
dsf_pkg_dir = Path(self.build_lib) / "dsf"
175-
dsf_pkg_dir.mkdir(parents=True, exist_ok=True)
176-
177-
# Also copy to source directory for editable installs
178-
source_dsf_dir = Path(__file__).parent / "src" / "dsf"
179-
180-
for dll in tbb_dlls:
181-
print(f"Copying {dll} to {dsf_pkg_dir}")
182-
shutil.copy2(dll, dsf_pkg_dir)
183-
print(f"Copying {dll} to {source_dsf_dir}")
184-
shutil.copy2(dll, source_dsf_dir)
185-
else:
186-
print("Warning: No TBB DLLs found. This might cause import errors.")
187-
188126
def pre_build(self):
189127
"""Extracts doxygen documentation from XML files and creates a C++ unordered_map"""
190128

0 commit comments

Comments
 (0)