Skip to content

Commit

Permalink
[ESI][Runtime] Publish Windows wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
teqdruid committed Jul 17, 2024
1 parent 419de21 commit 4e0d6f1
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 26 deletions.
40 changes: 27 additions & 13 deletions .github/workflows/esiRuntimePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ jobs:
fail-fast: false
matrix:
config:
- os: ubuntu-20.04
cibw_build: cp38-manylinux_x86_64
- os: ubuntu-20.04
cibw_build: cp39-manylinux_x86_64
- os: ubuntu-20.04
cibw_build: cp310-manylinux_x86_64
- os: ubuntu-20.04
cibw_build: cp311-manylinux_x86_64
- os: ubuntu-20.04
cibw_build: cp312-manylinux_x86_64
#- os: ubuntu-20.04
# cibw_build: cp313-manylinux_x86_64
# - os: ubuntu-20.04
# cibw_build: cp38-manylinux_x86_64
# - os: ubuntu-20.04
# cibw_build: cp39-manylinux_x86_64
# - os: ubuntu-20.04
# cibw_build: cp310-manylinux_x86_64
# - os: ubuntu-20.04
# cibw_build: cp311-manylinux_x86_64
# - os: ubuntu-20.04
# cibw_build: cp312-manylinux_x86_64
- os: windows-2022
cibw_build: cp38-win_amd64
# - os: windows-2022
# cibw_build: cp39-win_amd64
# - os: windows-2022
# cibw_build: cp310-win_amd64
# - os: windows-2022
# cibw_build: cp311-win_amd64
# - os: windows-2022
# cibw_build: cp312-win_amd64

steps:
- name: Get CIRCT
Expand All @@ -40,7 +48,13 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Build additional c++ deps
shell: pwsh
if: runner.os == 'Windows'
run: |
& "${env:VCPKG_INSTALLATION_ROOT}/vcpkg" --triplet x64-windows install zlib grpc
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2
Expand Down
28 changes: 20 additions & 8 deletions lib/Dialect/ESI/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ else()
COMPONENT ESIRuntime
)
endif()
install(IMPORTED_RUNTIME_ARTIFACTS ESICppRuntime
RUNTIME_DEPENDENCY_SET ESICppRuntime_RUNTIME_DEPS
COMPONENT ESIRuntime
)
install(FILES ${ESICppRuntimeHeaders}
DESTINATION include/esi
COMPONENT ESIRuntime-dev
Expand Down Expand Up @@ -238,18 +242,25 @@ if(Python3_FOUND)
$<TARGET_FILE:esiCppAccel>
"${CMAKE_CURRENT_BINARY_DIR}/python/esiaccel/$<TARGET_FILE_NAME:esiCppAccel>"
)

if (WHEEL_BUILD)
install(TARGETS esiCppAccel
DESTINATION .
COMPONENT ESIRuntime
)
set (ESI_PYTHON_INSTALL_DIR ".")
else()
install(TARGETS esiCppAccel
DESTINATION python/esiaccel
COMPONENT ESIRuntime
)
set (ESI_PYTHON_INSTALL_DIR "python/esiaccel")
endif()

install(TARGETS esiCppAccel
DESTINATION ${ESI_PYTHON_INSTALL_DIR}
COMPONENT ESIRuntime
)

install(RUNTIME_DEPENDENCY_SET ESICppRuntime_RUNTIME_DEPS
DESTINATION ${ESI_PYTHON_INSTALL_DIR}
PRE_EXCLUDE_REGEXES .*
PRE_INCLUDE_REGEXES zlibd1
COMPONENT ESIRuntime
)

foreach(pysrc ${ESIPythonRuntimeSources})
# Copy each of the Python sources to the build dir.
add_custom_command(
Expand Down Expand Up @@ -285,6 +296,7 @@ if(Python3_FOUND)
)

add_dependencies(ESIRuntime ESIPythonRuntime)

endif()
else() # Python not found.
if (WHEEL_BUILD)
Expand Down
26 changes: 21 additions & 5 deletions lib/Dialect/ESI/runtime/cpp/lib/Accelerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <linux/limits.h>
#include <unistd.h>
#elif _WIN32
// TODO: this.
#include <windows.h>
#endif

using namespace esi;
Expand Down Expand Up @@ -63,7 +63,11 @@ static std::filesystem::path getExePath() {
throw std::runtime_error("Could not get executable path");
return std::filesystem::path(std::string(result, count));
#elif _WIN32
// TODO: this.
char buffer[MAX_PATH];
DWORD length = GetModuleFileNameA(NULL, buffer, MAX_PATH);
if (length == 0)
throw std::runtime_error("Could not get executable path");
return std::filesystem::path(std::string(buffer, length));
#else
#eror "Unsupported platform"
#endif
Expand All @@ -76,7 +80,20 @@ static std::filesystem::path getLibPath() {
dladdr((void *)getLibPath, &dl_info);
return std::filesystem::path(std::string(dl_info.dli_fname));
#elif _WIN32
// TODO: this.
HMODULE hModule = NULL;
if (!GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCSTR>(&getLibPath), &hModule)) {
// Handle error
return std::filesystem::path();
}

char buffer[MAX_PATH];
DWORD length = GetModuleFileNameA(hModule, buffer, MAX_PATH);
if (length == 0)
throw std::runtime_error("Could not get library path");

return std::filesystem::path(std::string(buffer, length));
#else
#eror "Unsupported platform"
#endif
Expand All @@ -92,8 +109,7 @@ static void loadBackend(std::string backend) {
#ifdef __linux__
std::string backendFileName = "lib" + backend + "Backend.so";
#elif _WIN32
// TODO: this.
return;
std::string backendFileName = backend + "Backend.dll";
#else
#eror "Unsupported platform"
#endif
Expand Down
5 changes: 5 additions & 0 deletions lib/Dialect/ESI/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ def run(self):
if cc is not None:
cmake_args.append("-DCMAKE_C_COMPILER={}".format(cc))

if "VCPKG_INSTALLATION_ROOT" in os.environ:
cmake_args.append(
f"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
)

if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
cmake_args += os.environ["CIRCT_EXTRA_CMAKE_ARGS"].split(" ")

Expand Down

0 comments on commit 4e0d6f1

Please sign in to comment.