Skip to content

Commit

Permalink
[ESI runtime] Fix Python wheel build
Browse files Browse the repository at this point in the history
- Older versions of Linux (like the ones we use for Python wheel builds)
need more includes.
- Install backend shared libraries
- Exclude MtiPli from repair
  • Loading branch information
teqdruid committed Jul 10, 2024
1 parent 63ab38c commit 40fc3e6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
50 changes: 40 additions & 10 deletions lib/Dialect/ESI/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ if (NOT TARGET nlohmann_json)
FetchContent_MakeAvailable(json)
endif()

# In a Python wheel build, we need to install libraries to different places.
option(WHEEL_BUILD "Set up the build for a Python wheel." OFF)
if (WHEEL_BUILD)
message(STATUS "Setting up for a Python wheel build.")
endif()

##===----------------------------------------------------------------------===//
## Overall target to build everything.
##===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -113,10 +119,17 @@ else()
)
endif()
add_dependencies(ESIRuntime ESICppRuntime)
install(TARGETS ESICppRuntime
DESTINATION lib
COMPONENT ESIRuntime
)
if (WHEEL_BUILD)
install(TARGETS ESICppRuntime
DESTINATION lib
COMPONENT ESIRuntime
)
else()
install(TARGETS ESICppRuntime
DESTINATION python/esiaccel
COMPONENT ESIRuntime
)
endif()
install(FILES ${ESICppRuntimeHeaders}
DESTINATION include/esi
COMPONENT ESIRuntime-dev
Expand Down Expand Up @@ -165,11 +178,6 @@ add_dependencies(ESIRuntime esitester)
## Python bindings for the ESI runtime.
##===----------------------------------------------------------------------===//

option(WHEEL_BUILD "Set up the build for a Python wheel." OFF)
if (WHEEL_BUILD)
message(STATUS "Setting up for a Python wheel build.")
endif()

# Pybind11 is used to wrap the ESICppRuntime APIs.
if(NOT DEFINED Python3_FOUND)
find_package(Python3 COMPONENTS Interpreter Development)
Expand Down Expand Up @@ -284,7 +292,6 @@ else() # Python not found.
endif()



##===----------------------------------------------------------------------===//
## Backends are loaded dynamically as plugins.
##===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -331,6 +338,18 @@ if(ESI_COSIM)

add_dependencies(ESIRuntime CosimBackend)

if (WHEEL_BUILD)
install(TARGETS CosimBackend
DESTINATION lib
COMPONENT ESIRuntime
)
else()
install(TARGETS CosimBackend
DESTINATION python/esiaccel
COMPONENT ESIRuntime
)
endif()

# Build the RTL DPI cosim server.
add_subdirectory(cosim_dpi_server)
else()
Expand Down Expand Up @@ -365,6 +384,17 @@ if (XRT_PATH)
-L${XRT_PATH}/lib
)
add_dependencies(ESIRuntime XrtBackend)
if (WHEEL_BUILD)
install(TARGETS XrtBackend
DESTINATION lib
COMPONENT ESIRuntime
)
else()
install(TARGETS XrtBackend
DESTINATION python/esiaccel
COMPONENT ESIRuntime
)
endif()
endif()

install(FILES ${ESICppRuntimeBackendHeaders}
Expand Down
2 changes: 2 additions & 0 deletions lib/Dialect/ESI/runtime/cpp/lib/Accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

#ifdef __linux__
#include <dlfcn.h>
#include <linux/limits.h>
#include <unistd.h>
#elif _WIN32
// TODO: this.
#endif
Expand Down
3 changes: 3 additions & 0 deletions lib/Dialect/ESI/runtime/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ git_describe_command = "git describe --dirty --tags --long --match ESIRuntime*"
[tool.cibuildwheel]
build-frontend = "build"

[tool.cibuildwheel.linux]
repair-wheel-command = "auditwheel repair --exclude libMtiPli.so -w {dest_dir} {wheel}"

[project]
name = "esiaccel"
dynamic = ["version"]
Expand Down
3 changes: 0 additions & 3 deletions lib/Dialect/ESI/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ def run(self):
"--parallel",
"--target",
"ESIRuntime",
"esiquery",
"ESIPythonRuntime",
"EsiCosimDpiServer",
],
cwd=cmake_build_dir)

Expand Down

0 comments on commit 40fc3e6

Please sign in to comment.