Skip to content

Commit

Permalink
Terra main vs stable install switch
Browse files Browse the repository at this point in the history
  • Loading branch information
woodsp-ibm committed May 6, 2023
1 parent 1b9a154 commit 6cb38ce
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 97 deletions.
141 changes: 45 additions & 96 deletions .github/actions/install-main-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ inputs:
python-version:
description: 'Python version'
required: true
terra-main:
description: 'Use Terra main'
required: true
runs:
using: "composite"
steps:
- name: Get main last commit ids
run: |
echo "TERRA_HASH=$(git ls-remote --heads https://github.com/Qiskit/qiskit-terra.git refs/heads/main | awk '{print $1}')" >> $GITHUB_ENV
echo "AER_HASH=$(git ls-remote --heads https://github.com/Qiskit/qiskit-aer.git refs/heads/main | awk '{print $1}')" >> $GITHUB_ENV
echo "OPTIMIZATION_HASH=$(git ls-remote --heads https://github.com/Qiskit/qiskit-optimization.git refs/heads/main | awk '{print $1}')" >> $GITHUB_ENV
shell: bash
- name: Terra Cache
Expand All @@ -36,14 +38,6 @@ runs:
with:
path: terra-cache
key: terra-cache-${{ inputs.os }}-${{ inputs.python-version }}-${{ env.TERRA_HASH }}-${{ env.CACHE_VERSION }}
- name: Aer Cache
env:
CACHE_VERSION: v1
id: aer-cache
uses: actions/cache@v3
with:
path: aer-cache
key: aer-cache-${{ inputs.os }}-${{ inputs.python-version }}-${{ env.AER_HASH }}-${{ env.CACHE_VERSION }}
- name: Optimization Cache
env:
CACHE_VERSION: v1
Expand All @@ -56,102 +50,57 @@ runs:
env:
MACOSX_DEPLOYMENT_TARGET: 10.15
run: |
echo 'Install Terra from Main'
if [ "${{ inputs.os }}" == "windows-2019" ]; then
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
BASE_DIR=terra-cache
build_from_main=true
cache_hit=${{ steps.terra-cache.outputs.cache-hit }}
echo "cache hit: ${cache_hit}"
if [ "$cache_hit" == "true" ]; then
pip_result=0
pushd "${BASE_DIR}"
python -m pip install *.whl && pip_result=$? || pip_result=$?
popd
if [ $pip_result == 0 ]; then
build_from_main=false
if [ "${{ inputs.terra-main }}" == "true" ]; then
echo 'Install Terra from Main'
if [ "${{ inputs.os }}" == "windows-2019" ]; then
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
else
mkdir -p ${BASE_DIR}
fi
if [ "$build_from_main" == "true" ]; then
echo 'Create wheel file from main'
pip install -U wheel setuptools_rust
git clone --depth 1 --branch main https://github.com/Qiskit/qiskit-terra.git /tmp/qiskit-terra
pushd /tmp/qiskit-terra
python setup.py bdist_wheel
popd
cp -rf /tmp/qiskit-terra/dist/*.whl "${BASE_DIR}"
pushd "${BASE_DIR}"
python -m pip install *.whl
popd
pip uninstall -y setuptools_rust
fi
shell: bash
- name: Install Aer from Main
env:
MACOSX_DEPLOYMENT_TARGET: 10.16
run: |
echo 'Install Aer from Main'
if [ "${{ inputs.os }}" == "windows-2019" ]; then
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
if [ "${{ inputs.os }}" == "ubuntu-latest" ]; then
export DISABLE_CONAN=1
sudo apt-get -y install nlohmann-json3-dev
sudo apt-get -y install libspdlog-dev
sudo apt-get -y install libmuparserx-dev
fi
git clone --depth 1 --branch main https://github.com/Qiskit/qiskit-aer.git /tmp/qiskit-aer
BASE_DIR=aer-cache
build_from_main=true
cache_hit=${{ steps.aer-cache.outputs.cache-hit }}
echo "cache hit: ${cache_hit}"
if [ "$cache_hit" == "true" ]; then
pip_result=0
pushd "${BASE_DIR}"
python -m pip install *.whl && pip_result=$? || pip_result=$?
popd
if [ $pip_result == 0 ]; then
echo 'Verifying cached Aer with tools/verify_wheels.py ...'
verify_result=0
pushd /tmp/qiskit-aer
python tools/verify_wheels.py && verify_result=$? || verify_result=$?
BASE_DIR=terra-cache
build_from_main=true
cache_hit=${{ steps.terra-cache.outputs.cache-hit }}
echo "cache hit: ${cache_hit}"
if [ "$cache_hit" == "true" ]; then
pip_result=0
pushd "${BASE_DIR}"
python -m pip install *.whl && pip_result=$? || pip_result=$?
popd
if [ $verify_result == 0 ]; then
echo 'Cached Aer passed verification.'
if [ $pip_result == 0 ]; then
build_from_main=false
else
echo 'Cached Aer failed verification.'
pip uninstall -y qiskit-aer
fi
else
mkdir -p ${BASE_DIR}
fi
if [ "$build_from_main" == "true" ]; then
echo 'Create wheel file from main'
pip install -U wheel setuptools_rust
git clone --depth 1 --branch main https://github.com/Qiskit/qiskit-terra.git /tmp/qiskit-terra
pushd /tmp/qiskit-terra
python setup.py bdist_wheel
popd
cp -rf /tmp/qiskit-terra/dist/*.whl "${BASE_DIR}"
pushd "${BASE_DIR}"
python -m pip install *.whl
popd
pip uninstall -y setuptools_rust
fi
else
mkdir -p ${BASE_DIR}
fi
if [ "$build_from_main" == "true" ]; then
echo 'Create wheel file from main'
pip install -U wheel
pushd /tmp/qiskit-aer
pip install -U -c constraints.txt -r requirements-dev.txt
pip install pybind11
echo 'Install Terra from Stable'
if [ "${{ inputs.os }}" == "windows-2019" ]; then
python setup.py bdist_wheel -- -G 'Visual Studio 16 2019'
elif [ "${{ inputs.os }}" == "macos-latest" ]; then
pip install -U -c constraints.txt -r requirements-dev.txt
python setup.py bdist_wheel --plat-name macosx-10.16-x86_64
else
python setup.py bdist_wheel
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
popd
cp -rf /tmp/qiskit-aer/dist/*.whl "${BASE_DIR}"
pushd "${BASE_DIR}"
python -m pip install *.whl
popd
pip install -U qiskit-terra
fi
shell: bash
- name: Install stable Aer
run: |
echo 'Install stable Aer'
if [ "${{ inputs.os }}" == "windows-2019" ]; then
source "$CONDA/etc/profile.d/conda.sh"
conda activate scsenv
fi
pip install -U qiskit-aer
shell: bash
- name: Install Optimization from Main
run: |
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of Qiskit.
#
# (C) Copyright IBM 2021, 2022.
# (C) Copyright IBM 2021, 2023.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand Down Expand Up @@ -58,6 +58,7 @@ jobs:
with:
os: ${{ matrix.os }}
python-version: ${{ matrix.python-version }}
terra-main: "false"
if: ${{ !startsWith(github.ref, 'refs/heads/stable') && !startsWith(github.base_ref, 'stable/') }}
- uses: ./.github/actions/install-finance
with:
Expand Down

0 comments on commit 6cb38ce

Please sign in to comment.