Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions .github/workflows/scripts/build_wheels.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# ============================================================================ #
# Copyright (c) 2024 - 2025 NVIDIA Corporation & Affiliates. #
Expand All @@ -8,7 +8,7 @@
# the terms of the Apache License 2.0 which accompanies this distribution. #
# ============================================================================ #

set -e # Exit immediately if a command exits with a non-zero status
set -euo pipefail

# ==============================================================================
# Handling options
Expand All @@ -35,44 +35,44 @@ parse_options() {
while (( $# > 0 )); do
case "$1" in
--build-type)
if [[ -n "$2" && "$2" != -* ]]; then
build_type=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
build_type="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--cuda-version)
if [[ -n "$2" && "$2" != -* ]]; then
cuda_version=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
cuda_version="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--cudaq-prefix)
if [[ -n "$2" && "$2" != -* ]]; then
cudaq_prefix=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
cudaq_prefix="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--python-version)
if [[ -n "$2" && "$2" != -* ]]; then
python_version=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
python_version="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
exit 1
fi
;;
--tensorrt-path)
if [[ -n "$2" && "$2" != -* ]]; then
tensorrt_path=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
tensorrt_path="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
Expand All @@ -84,8 +84,8 @@ parse_options() {
shift 1
;;
--version)
if [[ -n "$2" && "$2" != -* ]]; then
wheels_version=("$2")
if [[ -n "${2:-}" && "${2:-}" != -* ]]; then
wheels_version="$2"
shift 2
else
echo "Error: Argument for $1 is missing" >&2
Expand Down Expand Up @@ -151,7 +151,7 @@ export CUDAQX_SOLVERS_VERSION=$wheels_version
# find the library on its own. Resolve the wheel's install prefix here and
# export CUQUANTUM_ROOT so the isolated build env's CMake invocation picks it
# up. Honors a pre-set CUQUANTUM_ROOT (e.g. for system installs).
if [ -z "$CUQUANTUM_ROOT" ]; then
if [ -z "${CUQUANTUM_ROOT:-}" ]; then
$python -m pip install --upgrade "cuquantum-python-cu${cuda_version}>=26.3.0"
CUQUANTUM_ROOT=$($python -m pip show "custabilizer-cu${cuda_version}" 2>/dev/null \
| sed -nE 's|^Location: (.*)|\1/cuquantum|p')
Expand Down Expand Up @@ -182,7 +182,7 @@ $python -m build --wheel
CUDAQ_EXCLUDE_LIST=$(for f in $(find $cudaq_prefix/lib -name "*.so" -printf "%P\n" | sort); do echo "--exclude $f"; done | tr '\n' ' ')

# We need to exclude a few libraries to prevent auditwheel from mistakenly grafting them into the wheel.
LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/_skbuild/lib:$tensorrt_path/lib" \
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$(pwd)/_skbuild/lib:$tensorrt_path/lib" \
$python -m auditwheel -v repair dist/*.whl $CUDAQ_EXCLUDE_LIST \
--wheel-dir /wheels \
--exclude libcudart.so.${cuda_version} \
Expand All @@ -208,7 +208,7 @@ SKBUILD_CMAKE_ARGS+=";-DCMAKE_BUILD_TYPE=$build_type" \
export SKBUILD_CMAKE_ARGS
$python -m build --wheel

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/_skbuild/lib" \
LD_LIBRARY_PATH="${LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}$(pwd)/_skbuild/lib" \
$python -m auditwheel -v repair dist/*.whl $CUDAQ_EXCLUDE_LIST \
--exclude libgfortran.so.5 \
--exclude libquadmath.so.0 \
Expand Down