Fix RPATH in pybind11 module for 0.33 #3890
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Wheel::Windows::x86_64 | |
# **What it does**: Builds python wheels for Windows (windows-latest) and store it as artifacts. | |
# Python versions: 3.9, 3.10, 3.11. | |
# **Why we have it**: To build wheels for pennylane-lightning installation. | |
# **Who does it impact**: Wheels to be uploaded to PyPI. | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
release: | |
types: [published] | |
env: | |
DISTUTILS_USE_SDK: 1 | |
MSSdk: 1 | |
concurrency: | |
group: wheel_win_x86_64-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
set_wheel_build_matrix: | |
name: "Set wheel build matrix" | |
uses: ./.github/workflows/set_wheel_build_matrix.yml | |
with: | |
event_name: ${{ github.event_name }} | |
build_dependencies: | |
needs: [set_wheel_build_matrix] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2022] | |
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }} | |
timeout-minutes: 30 | |
name: Kokkos core (${{ matrix.exec_model }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Cache installation directories | |
id: kokkos-cache | |
uses: actions/cache@v3 | |
with: | |
path: D:\a\install_dir\${{ matrix.exec_model }} | |
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-RelWithDebInfo | |
- name: Clone Kokkos libs | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
cd D:\a | |
git clone --branch ${{ matrix.kokkos_version }} https://github.com/kokkos/kokkos.git | |
- name: Create installation directory | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
Remove-Item -Path D:\a\install_dir\${{ matrix.exec_model }} -Recurse -Force -ErrorAction Ignore | |
mkdir -p D:\a\install_dir\${{ matrix.exec_model }} | |
- name: Install dependencies | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
python -m pip install cmake build | |
- name: Build Kokkos core library | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
cd D:\a\kokkos | |
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=D:\a\install_dir\${{ matrix.exec_model }} ` | |
-DKokkos_ENABLE_COMPLEX_ALIGN=OFF ` | |
-DKokkos_ENABLE_SERIAL=ON ` | |
-DKokkos_ENABLE_${{ matrix.exec_model }}=ON ` | |
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF ` | |
-DCMAKE_CXX_STANDARD=20 ` | |
-DCMAKE_POSITION_INDEPENDENT_CODE=ON ` | |
-DCMAKE_BUILD_TYPE=RelWithDebInfo ` | |
-T clangcl | |
cmake --build ./Build --config RelWithDebInfo --verbose | |
cmake --install ./Build --config RelWithDebInfo --verbose | |
win-wheels: | |
needs: [set_wheel_build_matrix, build_dependencies] | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [windows-2022] | |
arch: [AMD64] | |
pl_backend: ["lightning_qubit"] | |
cibw_build: ${{ fromJson(needs.set_wheel_build_matrix.outputs.python_version) }} | |
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }} | |
timeout-minutes: 30 | |
name: ${{ matrix.os }} - ${{ matrix.pl_backend }} (Python ${{ fromJson('{ "cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11" }')[matrix.cibw_build] }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Restoring cached dependencies | |
id: kokkos-cache | |
uses: actions/cache@v3 | |
with: | |
path: D:\a\install_dir\${{ matrix.exec_model }} | |
key: ${{ matrix.os }}-kokkos${{ matrix.kokkos_version }}-${{ matrix.exec_model }}-RelWithDebInfo | |
- name: Checkout PennyLane-Lightning | |
uses: actions/checkout@v3 | |
- name: Copy cached libraries #Update when merging to pennylane-lightning | |
if: steps.kokkos-cache.outputs.cache-hit == 'true' | |
run: | | |
Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" ` | |
-Destination "D:\a\Lightning-Unification\Lightning-Unification\Kokkos" -Recurse -Force | |
- name: Install cibuildwheel | |
run: python -m pip install cibuildwheel~=2.11.0 wheel | |
- name: Build wheels | |
env: | |
CIBW_ARCHS_WINDOWS: ${{matrix.arch}} | |
CIBW_BUILD: ${{ matrix.cibw_build }} | |
# Python build settings | |
CIBW_BEFORE_BUILD: | | |
python -m pip install pybind11 cmake~=3.24.0 build | |
# Testing of built wheels | |
CIBW_TEST_REQUIRES: pytest pytest-cov pytest-mock flaky | |
CIBW_BEFORE_TEST: | | |
python -m pip install git+https://github.com/PennyLaneAI/[email protected] | |
CIBW_TEST_COMMAND: | | |
pl-device-test --device=lightning.qubit --skip-ops -x --tb=short --no-flaky-report | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_BUILD_VERBOSITY: 3 | |
CIBW_BUILD_FRONTEND: build | |
run: python -m cibuildwheel --output-dir wheelhouse | |
- name: Patch wheels | |
run: | | |
cd wheelhouse | |
$wheels = Get-ChildItem "./" -Filter *.whl | |
foreach ($i in $wheels){ | |
python -m wheel unpack $i.Name | |
$name = $i.Name | |
$dirName = python -c "s = '$name'; print('-'.join(s.split('-')[0:2]))" | |
if (Test-Path -Path $dirName\pennylane_lightning\RelWithDebInfo) { | |
Move-Item -Path $dirName\pennylane_lightning\RelWithDebInfo\* -Destination $dirName\pennylane_lightning | |
Remove-Item $dirName\pennylane_lightning\RelWithDebInfo -Recurse | |
python -m wheel pack $dirName | |
echo "Patched $name" | |
} | |
Remove-Item $dirName -Recurse | |
} | |
cd .. | |
- name: Validate wheels | |
run: | | |
python -m pip install twine | |
python -m twine check ./wheelhouse/*.whl | |
- uses: actions-ecosystem/action-regex-match@main | |
id: rc_build | |
with: | |
text: ${{ github.event.pull_request.head.ref }} | |
regex: '.*[0-9]+.[0-9]+.[0-9]+[-_]?rc[0-9]+' | |
- uses: actions/upload-artifact@v3 | |
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master' || steps.rc_build.outputs.match != ''}} | |
with: | |
name: ${{ runner.os }}-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip | |
path: ./wheelhouse/*.whl | |
upload-pypi: | |
needs: win-wheels | |
strategy: | |
matrix: | |
arch: [AMD64] | |
pl_backend: ["lightning_qubit"] | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}} | |
steps: | |
- uses: actions/download-artifact@v3 | |
with: | |
name: Windows-wheels-${{ matrix.pl_backend }}-${{ matrix.arch }}.zip | |
path: dist | |
- name: Upload wheels to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ |