Skip to content

Commit aa49e6d

Browse files
committed
These should not be necessary anymore
1 parent b2e142b commit aa49e6d

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

.github/workflows/binding.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
if: matrix.os == 'ubuntu-latest'
3333
run: |
3434
sudo apt update
35-
sudo apt install -y cmake build-essential libtbb-dev libspdlog-dev libsimdjson-dev doxygen
35+
sudo apt install -y cmake build-essential doxygen
3636
3737
- name: Install system dependencies (macOS)
3838
if: matrix.os == 'macos-latest'
@@ -189,7 +189,7 @@ jobs:
189189
- name: Install system dependencies
190190
run: |
191191
sudo apt update
192-
sudo apt install -y cmake build-essential libtbb-dev libspdlog-dev libsimdjson-dev doxygen
192+
sudo apt install -y cmake build-essential doxygen
193193
194194
- name: Install development dependencies
195195
run: |

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ if(NOT CMAKE_BUILD_TYPE)
3939
endif()
4040
if(BUILD_PYTHON_BINDINGS)
4141
set(DSF_BUILD_PIC ON)
42+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
4243
endif()
4344

4445
# Set the C++ standard
@@ -133,6 +134,8 @@ endif()
133134
set(TBB_TEST OFF CACHE BOOL "Disable TBB tests" FORCE)
134135
set(TBB_EXAMPLES OFF CACHE BOOL "Disable TBB examples" FORCE)
135136
set(TBB_STRICT OFF CACHE BOOL "Disable TBB strict mode" FORCE)
137+
# set(TBB_BUILD_SHARED ON CACHE BOOL "Build TBB as shared library" FORCE)
138+
# set(TBB_BUILD_TBBMALLOC OFF CACHE BOOL "Disable TBB malloc" FORCE)
136139

137140
FetchContent_Declare(
138141
tbb
@@ -225,6 +228,11 @@ if(BUILD_PYTHON_BINDINGS)
225228
PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
226229
INSTALL_RPATH "${HOMEBREW_LIB}"
227230
INSTALL_RPATH_USE_LINK_PATH TRUE)
231+
elseif(UNIX)
232+
set_target_properties(
233+
dsf_python_module
234+
PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE
235+
INSTALL_RPATH "$ORIGIN")
228236
endif()
229237
endif()
230238

setup.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,32 @@ def build_extension(self, ext: CMakeExtension):
123123
cwd=build_temp,
124124
)
125125

126+
# Copy TBB shared library if it exists (Linux only)
127+
if platform.system() == "Linux":
128+
print(f"Searching for TBB shared libraries in {build_temp}...")
129+
# Look for libtbb.so* recursively
130+
tbb_libs = list(build_temp.glob("**/libtbb.so*"))
131+
# Also look for libtbb_debug.so* if we are in debug mode or if that's what was built
132+
tbb_libs.extend(list(build_temp.glob("**/libtbb_debug.so*")))
133+
134+
if tbb_libs:
135+
print(f"Found TBB libraries: {tbb_libs}")
136+
for lib in tbb_libs:
137+
# We only want the real shared object, not symlinks if possible,
138+
# but copying everything matching the pattern is safer to ensure we get the versioned one.
139+
# However, we need to be careful not to overwrite if multiple matches found.
140+
# Usually we want the one that the linker linked against.
141+
# Since we set RPATH to $ORIGIN, we need the library in the same dir as the extension.
142+
143+
# Avoid copying if it's a symlink pointing to something we already copied?
144+
# simpler: just copy all of them.
145+
dest = extdir / lib.name
146+
if not dest.exists():
147+
shutil.copy2(lib, dest)
148+
print(f"Copied {lib} to {dest}")
149+
else:
150+
print("Warning: No TBB shared libraries found to copy.")
151+
126152
def pre_build(self):
127153
"""Extracts doxygen documentation from XML files and creates a C++ unordered_map"""
128154

0 commit comments

Comments
 (0)