Refactor setup.py to align with CF. #3071
Workflow file for this run
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.8, 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 | |
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-2019] | |
exec_model: ${{ fromJson(needs.set_wheel_build_matrix.outputs.exec_model) }} | |
kokkos_version: ${{ fromJson(needs.set_wheel_build_matrix.outputs.kokkos_version) }} | |
name: Kokkos core & kernels (${{ matrix.exec_model }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Cancel previous runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- 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 https://github.com/kokkos/kokkos.git | |
cd D:\a\kokkos | |
git checkout ${{ matrix.kokkos_version }} | |
cd D:\a\ | |
git clone https://github.com/kokkos/kokkos-kernels.git | |
cd D:\a\kokkos-kernels | |
git checkout ${{ matrix.kokkos_version }} | |
cd .. | |
- 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_${{ 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 | |
- name: Build Kokkos kernels library | |
if: steps.kokkos-cache.outputs.cache-hit != 'true' | |
run: | | |
cd D:\a\kokkos-kernels | |
cmake -BBuild . -DCMAKE_INSTALL_PREFIX=D:\a\install_dir\${{ matrix.exec_model }} ` | |
-DKokkos_ENABLE_${{ matrix.exec_model }}=ON ` | |
-DCMAKE_CXX_STANDARD=20 ` | |
-DCMAKE_PREFIX_PATH=D:\a\install_dir\${{ matrix.exec_model }} ` | |
-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-2019] | |
arch: [AMD64] | |
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) }} | |
name: ${{ matrix.os }} (Python ${{ fromJson('{ "cp38-*":"3.8","cp39-*":"3.9","cp310-*":"3.10","cp311-*":"3.11" }')[matrix.cibw_build] }}) | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Cancel Previous Runs | |
uses: styfle/[email protected] | |
with: | |
access_token: ${{ github.token }} | |
- 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 | |
- uses: actions/checkout@v3 | |
- name: Copy cached libraries | |
if: steps.kokkos-cache.outputs.cache-hit == 'true' | |
run: | | |
Copy-Item -Path "D:\a\install_dir\${{ matrix.exec_model }}\" ` | |
-Destination "D:\a\pennylane-lightning\pennylane-lightning\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: | | |
pip install pybind11 cmake~=3.24.0 build | |
# Testing of built wheels | |
CIBW_TEST_REQUIRES: pytest pytest-cov pytest-mock flaky | |
CIBW_BEFORE_TEST: | | |
pip install git+https://github.com/PennyLaneAI/pennylane.git@master | |
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@v2 | |
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@v2 | |
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master' || steps.rc_build.outputs.match != ''}} | |
with: | |
name: ${{ runner.os }}-wheels-${{ matrix.arch }}.zip | |
path: ./wheelhouse/*.whl | |
upload-pypi: | |
needs: win-wheels | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'release' || github.ref == 'refs/heads/master'}} | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: Windows-wheels-AMD64.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/ |