Skip to content

Commit

Permalink
[ESI][Runtime] Publish Windows wheels (#7363)
Browse files Browse the repository at this point in the history
DLLs have to be installed to different locations on Windows.
  • Loading branch information
teqdruid authored Jul 22, 2024
1 parent 0102a61 commit 6aa8f9e
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 43 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/esiRuntimePublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,16 @@ jobs:
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: 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,17 +48,43 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Install deps with choco (Windows)
shell: pwsh
if: runner.os == 'Windows'
run: choco install ninja

- name: Build additional c++ deps (Windows)
shell: pwsh
if: runner.os == 'Windows'
# TODO: cache the binaries produced by vcpkg to save ~1hr of build time:
# https://learn.microsoft.com/en-us/vcpkg/consume/binary-caching-github-packages?pivots=windows-runner
run: |
& "${env:VCPKG_INSTALLATION_ROOT}/vcpkg" --triplet x64-windows install zlib
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.2

- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse ./lib/Dialect/ESI/runtime
if: runner.os != 'Windows'
env:
CIBW_BUILD: ${{ matrix.config.cibw_build }}
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/circt/images/pycde-build
SETUPTOOLS_SCM_DEBUG: True
run: python -m cibuildwheel --output-dir wheelhouse ./lib/Dialect/ESI/runtime

- name: Build wheels (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
CIBW_BUILD: ${{ matrix.config.cibw_build }}
SETUPTOOLS_SCM_DEBUG: True
CIRCT_EXTRA_CMAKE_ARGS: -DESI_COSIM=OFF
run: |
echo "Building wheel"
& "${env:GITHUB_WORKSPACE}\utils\find-vs.ps1"
python3 -m cibuildwheel --output-dir wheelhouse ./lib/Dialect/ESI/runtime
- name: Get wheel name
shell: bash
Expand Down
67 changes: 29 additions & 38 deletions lib/Dialect/ESI/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,19 @@ if(NOT MSVC)
endif()
add_dependencies(ESIRuntime ESICppRuntime)
if (WHEEL_BUILD)
install(TARGETS ESICppRuntime
DESTINATION lib
COMPONENT ESIRuntime
)
if (WIN32)
set(PYLIBDIR ".")
else()
set(PYLIBDIR "lib")
endif()
else()
install(TARGETS ESICppRuntime
DESTINATION python/esiaccel
COMPONENT ESIRuntime
)
set(PYLIBDIR "python/esiaccel")
endif()
install(TARGETS ESICppRuntime
DESTINATION ${PYLIBDIR}
COMPONENT ESIRuntime
)

install(IMPORTED_RUNTIME_ARTIFACTS ESICppRuntime
RUNTIME_DEPENDENCY_SET ESICppRuntime_RUNTIME_DEPS
COMPONENT ESIRuntime
Expand Down Expand Up @@ -279,18 +282,20 @@ if(Python3_FOUND)
$<TARGET_FILE:esiCppAccel>
"${CMAKE_CURRENT_BINARY_DIR}/python/esiaccel/$<TARGET_FILE_NAME:esiCppAccel>"
)

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

install(TARGETS esiCppAccel
DESTINATION ${ESI_PYTHON_INSTALL_DIR}
COMPONENT ESIRuntime
)
install(RUNTIME_DEPENDENCY_SET ESICppRuntime_RUNTIME_DEPS
DESTINATION ${ESI_PYTHON_INSTALL_DIR}
DESTINATION ${PYLIBDIR}
PRE_EXCLUDE_REGEXES .*
PRE_INCLUDE_REGEXES zlibd zlib
COMPONENT ESIRuntime
Expand Down Expand Up @@ -386,17 +391,10 @@ 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()
install(TARGETS CosimBackend
DESTINATION ${PYLIBDIR}
COMPONENT ESIRuntime
)

# Build the RTL DPI cosim server.
add_subdirectory(cosim_dpi_server)
Expand Down Expand Up @@ -432,17 +430,10 @@ 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()
install(TARGETS XrtBackend
DESTINATION ${PYLIBDIR}
COMPONENT ESIRuntime
)
endif()

install(FILES ${ESICppRuntimeBackendHeaders}
Expand Down
7 changes: 6 additions & 1 deletion lib/Dialect/ESI/runtime/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ def run(self):
# Configure the build.
cfg = "Release"
cmake_args = [
"-GNinja", # This build only works with Ninja on Windows.
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
"-DPython3_EXECUTABLE={}".format(sys.executable.replace("\\", "/")),
"-DWHEEL_BUILD=ON",
"-GNinja",
]
cxx = os.getenv("CXX")
if cxx is not None:
Expand All @@ -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 6aa8f9e

Please sign in to comment.