Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to create wheels in devdeps images #58

Merged
merged 2 commits into from
Jan 22, 2025
Merged
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
37 changes: 30 additions & 7 deletions .github/workflows/scripts/build_wheels.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/sh

# ============================================================================ #
# Copyright (c) 2022 - 2024 NVIDIA Corporation & Affiliates. #
# Copyright (c) 2024 - 2025 NVIDIA Corporation & Affiliates. #
# All rights reserved. #
# #
# This source code and the accompanying materials are made available under #
# 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

# ==============================================================================
# Handling options
Expand All @@ -20,6 +21,9 @@ show_help() {
echo " --cudaq-prefix Path to CUDA-Q's install prefix"
echo " (default: \$HOME/.cudaq)"
echo " --python-version Python version to build wheel for (e.g. 3.10)"
echo " --devdeps Build wheels suitable for internal testing"
echo " (not suitable for distribution but sometimes"
echo " helpful for debugging)"
}

parse_options() {
Expand Down Expand Up @@ -52,6 +56,10 @@ parse_options() {
exit 1
fi
;;
--devdeps)
devdeps=true
shift 1
;;
-*)
echo "Error: Unknown option $1" >&2
show_help
Expand All @@ -70,6 +78,7 @@ parse_options() {
cudaq_prefix=$HOME/.cudaq
build_type=Release
python_version=3.10
devdeps=false

# Parse options
parse_options "$@"
Expand All @@ -82,9 +91,14 @@ echo "Building in $build_type mode for Python $python_version"

python=python${python_version}
ARCH=$(uname -m)
PLAT_STR=""

# We need to use a newer toolchain because CUDA-QX libraries rely on c++20
source /opt/rh/gcc-toolset-11/enable
if $devdeps; then
PLAT_STR="--plat manylinux_2_34_x86_64"
else
# We need to use a newer toolchain because CUDA-QX libraries rely on c++20
source /opt/rh/gcc-toolset-11/enable
fi

export CC=gcc
export CXX=g++
Expand All @@ -96,7 +110,9 @@ export CXX=g++
cd libs/qec

SKBUILD_CMAKE_ARGS="-DCUDAQ_DIR=$cudaq_prefix/lib/cmake/cudaq"
SKBUILD_CMAKE_ARGS+=";-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=/opt/rh/gcc-toolset-11/root/usr/lib/gcc/${ARCH}-redhat-linux/11/"
if ! $devdeps; then
SKBUILD_CMAKE_ARGS+=";-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=/opt/rh/gcc-toolset-11/root/usr/lib/gcc/${ARCH}-redhat-linux/11/"
fi
SKBUILD_CMAKE_ARGS+=";-DCMAKE_BUILD_TYPE=$build_type"
export SKBUILD_CMAKE_ARGS
$python -m build --wheel
Expand All @@ -105,7 +121,8 @@ CUDAQ_EXCLUDE_LIST=$(for f in $(find $cudaq_prefix/lib -name "*.so" -printf "%P\

LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/_skbuild/lib" \
$python -m auditwheel -v repair dist/*.whl $CUDAQ_EXCLUDE_LIST \
--wheel-dir /wheels
--wheel-dir /wheels \
${PLAT_STR}

# ==============================================================================
# Solvers library
Expand All @@ -114,7 +131,9 @@ $python -m auditwheel -v repair dist/*.whl $CUDAQ_EXCLUDE_LIST \
cd ../solvers

SKBUILD_CMAKE_ARGS="-DCUDAQ_DIR=$cudaq_prefix/lib/cmake/cudaq"
SKBUILD_CMAKE_ARGS+=";-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=/opt/rh/gcc-toolset-11/root/usr/lib/gcc/${ARCH}-redhat-linux/11/;"
if ! $devdeps; then
SKBUILD_CMAKE_ARGS+=";-DCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN=/opt/rh/gcc-toolset-11/root/usr/lib/gcc/${ARCH}-redhat-linux/11/;"
fi
SKBUILD_CMAKE_ARGS+=";-DCMAKE_BUILD_TYPE=$build_type" \
export SKBUILD_CMAKE_ARGS
$python -m build --wheel
Expand All @@ -124,5 +143,9 @@ $python -m auditwheel -v repair dist/*.whl $CUDAQ_EXCLUDE_LIST \
--exclude libgfortran.so.5 \
--exclude libquadmath.so.0 \
--exclude libmvec.so.1 \
--wheel-dir /wheels
--wheel-dir /wheels \
${PLAT_STR}


echo "Wheel builds are complete: "
ls -la /wheels
Loading