From 314ad0e1ab30742ef9bd2140ed5c10084953d1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Di=20Remigio=20Eik=C3=A5s?= Date: Mon, 25 Sep 2023 15:08:46 +0200 Subject: [PATCH] refactor deploy.yml --- .github/workflows/deploy.yml | 342 ++++++++++------------------------- pyproject.toml | 41 +++++ 2 files changed, 138 insertions(+), 245 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fc5b9877d2..37c5cf1407 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,129 +1,84 @@ name: Deploy on: + workflow_dispatch: + pull_request: push: - tags: - - '*' + branches: + - master + release: + types: + - published + +env: + FORCE_COLOR: 3 + jobs: - wheel-build: - name: Build qiskit-aer wheels - strategy: - matrix: - os: ["macOS-latest", "ubuntu-latest", "windows-2019"] - runs-on: ${{ matrix.os }} + build-sdist: + name: Build SDist + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' + - uses: actions/checkout@v4 + + - name: Build SDist + run: pipx run build --sdist + + - name: Check metadata + run: pipx run twine check dist/* + + - uses: actions/upload-artifact@v3 + with: + path: dist/*.tar.gz + + generate-wheels-matrix: + name: Generate wheels matrix + runs-on: ubuntu-latest + outputs: + include: ${{ steps.set-matrix.outputs.include }} + steps: + - uses: actions/checkout@v4 - name: Install cibuildwheel + run: pipx install cibuildwheel==2.16.0 + - id: set-matrix run: | - python -m pip install cibuildwheel==2.11.2 - - name: Build wheels - env: - AER_CMAKE_OPENMP_BUILD: 1 - run: python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Publish Wheels - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - run : | - pip install -U twine - twine upload wheelhouse/* - build_wheels_aarch64: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} + MATRIX=$( + { + cibuildwheel --print-build-identifiers --platform linux \ + | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \ + && cibuildwheel --print-build-identifiers --platform macos \ + | jq -nRc '{"only": inputs, "os": "macos-latest"}' \ + && cibuildwheel --print-build-identifiers --platform windows \ + | jq -nRc '{"only": inputs, "os": "windows-latest"}' + } | jq -sc + ) + echo "include=$MATRIX" >> $GITHUB_OUTPUT + env: + CIBW_ARCHS_LINUX: x86_64 aarch64 s390x ppc64le + CIBW_ARCHS_MACOS: x86_64 arm64 + CIBW_ARCHS_WINDOWS: AMD64 + + build-wheels: + name: Build ${{ matrix.only }} + needs: generate-wheels-matrix strategy: - fail-fast: false matrix: - os: [ubuntu-latest] + include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' + - uses: actions/checkout@v4 + - uses: actions-rs/toolchain@v1 + if: contains(fromJSON('["aarch64", "ppc64le", "s390x"]'), matrix.only) with: toolchain: stable + - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 with: platforms: all - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.11.2 twine - - name: Build wheels - run: | - python -m cibuildwheel --output-dir wheelhouse - env: - CIBW_BEFORE_ALL_LINUX: "yum install -y https://dl.fedoraproject.org/pub/epel/7/aarch64/Packages/e/epel-release-7-12.noarch.rpm && yum install -y openblas-devel" - CIBW_ARCHS_LINUX: aarch64 - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Upload to PyPI - run: twine upload ./wheelhouse/*.whl - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - wheel-arm64-macos: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: ["macOS-latest"] - steps: - - uses: actions/checkout@v2 - - name: Set up Python Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - name: Install deps - run: python -m pip install -U cibuildwheel==2.11.2 twine - - name: Build Wheels - env: - CIBW_ARCHS_MACOS: arm64 - run: cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Upload to PyPI - run: twine upload ./wheelhouse/*.whl - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - sdist: - name: Publish qiskit-aer sdist - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - name: Install Deps - run: pip install -U twine wheel - - name: Build Artifacts - run: | - python setup.py sdist - shell: bash - - uses: actions/upload-artifact@v2 - with: - path: ./dist/qiskit* - - name: Publish to PyPi - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - run: twine upload dist/qiskit* - gpu-build-cuda11: - name: Build qiskit-aer-gpu-cu11 wheels - runs-on: ubuntu-latest - steps: + - name: Maximize build space + if: matrix.os == 'ubuntu-latest' uses: easimon/maximize-build-space@master with: root-reserve-mb: 40000 @@ -133,143 +88,40 @@ jobs: remove-haskell: 'true' remove-codeql: 'true' remove-docker-images: 'true' - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.11.2 - - name: Build wheels + + - uses: pypa/cibuildwheel@v2.16.0 env: - CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && rpm -i cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all" - CIBW_BEFORE_BUILD : "pip install nvidia-cuda-runtime-cu11 nvidia-cublas-cu11 nvidia-cusolver-cu11 nvidia-cusparse-cu11 cuquantum-cu11" - CIBW_SKIP: "*-manylinux_i686 pp* cp36* *musllinux*" - CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu-cu11 QISKIT_AER_CUDA_MAJOR=11 CMAKE_VERBOSE_MAKEFILE=true AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7" AER_PYTHON_CUDA_ROOT=/opt/_internal AER_CIBUILD=true - CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair --exclude libcudart.so.11.0 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusparse.so.11 --exclude libcublas.so.11 --exclude libcublasLt.so.11 -w {dest_dir} {wheel}' - run: | - python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 + CIBW_ENVIRONMENT: AER_CMAKE_OPENMP_BUILD=1 with: - path: ./wheelhouse/*.whl - - name: Publish Wheels - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - run : | - pip install -U twine - twine upload wheelhouse/* - gpu-build-cuda12: - name: Build qiskit-aer-gpu-cu12 wheels + only: ${{ matrix.only }} + + - name: Verify clean directory + run: git diff --exit-code + shell: bash + + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + path: wheelhouse/*.whl + + upload-all: + name: Upload if release + needs: + - build-wheels + - build-sdist runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + steps: - - name: Maximize build space - uses: easimon/maximize-build-space@master - with: - root-reserve-mb: 40000 - swap-size-mb: 1024 - remove-dotnet: 'true' - remove-android: 'true' - remove-haskell: 'true' - remove-codeql: 'true' - remove-docker-images: 'true' - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - name: Install cibuildwheel - run: | - python -m pip install cibuildwheel==2.11.2 - - name: Build wheels - env: - CIBW_BEFORE_ALL: "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-rhel7-12-1-local-12.1.1_530.30.02-1.x86_64.rpm && rpm -i cuda-repo-rhel7-12-1-local-12.1.1_530.30.02-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all" - CIBW_BEFORE_BUILD : "pip install nvidia-cuda-runtime-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12" - CIBW_SKIP: "*-manylinux_i686 pp* cp36* *musllinux*" - CIBW_ENVIRONMENT: QISKIT_AER_PACKAGE_NAME=qiskit-aer-gpu QISKIT_AER_CUDA_MAJOR=12 CMAKE_VERBOSE_MAKEFILE=true AER_THRUST_BACKEND=CUDA CUDACXX=/usr/local/cuda/bin/nvcc AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7 9.0" AER_PYTHON_CUDA_ROOT=/opt/_internal AER_CIBUILD=true - CIBW_REPAIR_WHEEL_COMMAND: 'auditwheel repair --exclude libcudart.so.12 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusolver.so.12 --exclude libcusolverMg.so.12 --exclude libcusparse.so.12 --exclude libcublas.so.12 --exclude libcublasLt.so.12 --exclude libnvJitLink.so.12 -w {dest_dir} {wheel}' - run: | - python -m cibuildwheel --output-dir wheelhouse - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Publish Wheels - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - run : | - pip install -U twine - twine upload wheelhouse/* - build_wheels_s390x: - name: Build wheels on s390x - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - with: - platforms: all - - name: Build wheels - uses: pypa/cibuildwheel@v2.11.2 - env: - CIBW_ARCHS_LINUX: s390x - CIBW_TEST_SKIP: "cp*" - CIBW_BEFORE_ALL: "yum install -y epel-release && yum install -y openblas-devel" - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Install twine - run: python -m pip install twine - - name: Upload to PyPI - run: twine upload ./wheelhouse/*.whl - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit - build_wheels_ppc64le: - name: Build wheels on ppc64le - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - name: Install Python - with: - python-version: '3.8' - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - with: - platforms: all - - name: Build wheels - uses: pypa/cibuildwheel@v2.11.2 - env: - CIBW_ARCHS_LINUX: ppc64le - CIBW_TEST_SKIP: "cp*" - CIBW_BEFORE_ALL: "yum install -y epel-release && yum install -y openblas-devel" - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - name: Install twine - run: python -m pip install twine - - name: Upload to PyPI - run: twine upload ./wheelhouse/*.whl - env: - TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - TWINE_USERNAME: qiskit + - uses: actions/setup-python@v4 + + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - uses: pypa/gh-action-pypi-publish@v1 + with: + user: __token__ + password: ${{ secrets.pypi_password }} + diff --git a/pyproject.toml b/pyproject.toml index 8bcfe1bdce..6c23617d2e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,6 +33,47 @@ environment = { CMAKE_GENERATOR = "Visual Studio 16 2019"} select = "cp3{8,9,10,11}-manylinux_i686" before-all = "yum install -y wget && bash {project}/tools/install_openblas_i686.sh && bash {project}/tools/install_rust.sh" +[[tool.cibuildwheel.overrides]] +select = "cp3{8,9,10,11}-manylinux_{ppc64le,s390x}" +before-all = "yum install -y epel-release && yum install -y openblas-devel" + +[[tool.cibuildwheel.overrides]] +select = "cp3{8,9,10,11}-manylinux_{aarch64}" +before-all-linux = "yum install -y https://dl.fedoraproject.org/pub/epel/7/aarch64/Packages/e/epel-release-7-12.noarch.rpm && yum install -y openblas-devel" + +[[tool.cibuildwheel.overrides]] +select = "*-gpu-*" +skip = "*-manylinux_i686 pp* cp36* *musllinux*" +environment = { + CMAKE_VERBOSE_MAKEFILE="true", + AER_THRUST_BACKEND="CUDA", + CUDACXX="/usr/local/cuda/bin/nvcc", + AER_PYTHON_CUDA_ROOT="/opt/_internal", + AER_CIBUILD="true", +} + +[[tool.cibuildwheel.overrides]] +select = "*-gpu-cu12" +before-all = "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-rhel7-12-1-local-12.1.1_530.30.02-1.x86_64.rpm && rpm -i cuda-repo-rhel7-12-1-local-12.1.1_530.30.02-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all" +before-build = "pip install nvidia-cuda-runtime-cu12 nvidia-cublas-cu12 nvidia-cusolver-cu12 nvidia-cusparse-cu12 cuquantum-cu12" +environment = { + QISKIT_AER_PACKAGE_NAME="qiskit-aer-gpu", + QISKIT_AER_CUDA_MAJOR="12", + AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7 9.0", +} +repair-wheel-command = 'auditwheel repair --exclude libcudart.so.12 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusolver.so.12 --exclude libcusolverMg.so.12 --exclude libcusparse.so.12 --exclude libcublas.so.12 --exclude libcublasLt.so.12 --exclude libnvJitLink.so.12 -w {dest_dir} {wheel}' + +[[tool.cibuildwheel.overrides]] +select = "*-gpu-cu11" +before-all = "yum install -y yum-utils wget && wget -q https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && rpm -i cuda-repo-rhel7-11-8-local-11.8.0_520.61.05-1.x86_64.rpm && yum clean all && yum -y install cuda && yum -y install openblas-devel && yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo && yum clean all" +before-build = "pip install nvidia-cuda-runtime-cu11 nvidia-cublas-cu11 nvidia-cusolver-cu11 nvidia-cusparse-cu11 cuquantum-cu11" +environment = { + QISKIT_AER_PACKAGE_NAME="qiskit-aer-gpu-cu11", + QISKIT_AER_CUDA_MAJOR="11", + AER_CUDA_ARCH="7.0 7.2 7.5 8.0 8.6 8.7", +} +repair-wheel-command = 'auditwheel repair --exclude libcudart.so.11.0 --exclude libcustatevec.so.1 --exclude libcutensornet.so.2 --exclude libcutensor.so.1 --exclude libcutensorMg.so.1 --exclude libcusolver.so.11 --exclude libcusolverMg.so.11 --exclude libcusparse.so.11 --exclude libcublas.so.11 --exclude libcublasLt.so.11 -w {dest_dir} {wheel}' + [tool.black] line-length = 100 target-version = ['py38', 'py39', 'py310', 'py311']