From f7f6cb1150d057249a0af04d72caac92780065c7 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Wed, 15 Nov 2023 15:42:19 +0100 Subject: [PATCH] Ensure metapackage is installed during CI and tox (#11119) * Ensure metapackage is installed during CI and tox This ensures that the local version of the metapackage is also built and installed on all CI runs (and in `tox`, where it's overridden) so that dependencies on the metapackage in our optionals (e.g. Aer) will not cause the older released version of Terra to be installed. `tox` does not like having two local packages under test simultaneously through its default configuration, so this fakes things out by putting the two packages in the run dependencies and setting `skip_install`. * Fix sdist build * Use regular installs for metapackage * Simplify build requirements install --- .azure/lint-linux.yml | 3 +++ .azure/test-linux.yml | 15 ++++++++++----- .azure/test-macos.yml | 3 +++ .azure/test-windows.yml | 3 +++ .github/workflows/coverage.yml | 2 +- .github/workflows/slow.yml | 2 +- tox.ini | 33 +++++++++++++++++---------------- 7 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.azure/lint-linux.yml b/.azure/lint-linux.yml index 532c2072ed..5855fe1e6e 100644 --- a/.azure/lint-linux.yml +++ b/.azure/lint-linux.yml @@ -26,7 +26,10 @@ jobs: -c constraints.txt \ -r requirements.txt \ -r requirements-dev.txt \ + ./qiskit_pkg \ -e . + # Build and install both qiskit and qiskit-terra so that any optionals + # depending on `qiskit` will resolve correctly. displayName: 'Install dependencies' env: SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" diff --git a/.azure/test-linux.yml b/.azure/test-linux.yml index 3268f29bd4..eb456f8497 100644 --- a/.azure/test-linux.yml +++ b/.azure/test-linux.yml @@ -71,15 +71,17 @@ jobs: # Use stable Rust, rather than MSRV, to spot-check that stable builds properly. rustup override set stable source test-job/bin/activate - python -m pip install -U pip setuptools wheel - # Install setuptools-rust for building sdist - python -m pip install -U -c constraints.txt setuptools-rust - python setup.py sdist + python -m pip install -U pip + python -m pip install -U build + python -m build --sdist . + python -m build --sdist qiskit_pkg python -m pip install -U \ -c constraints.txt \ -r requirements.txt \ -r requirements-dev.txt \ - dist/qiskit-terra*.tar.gz + dist/qiskit*.tar.gz + # Build and install both qiskit and qiskit-terra so that any optionals + # depending on `qiskit` will resolve correctly. displayName: "Install Terra from sdist" - ${{ if eq(parameters.installFromSdist, false) }}: @@ -90,7 +92,10 @@ jobs: -c constraints.txt \ -r requirements.txt \ -r requirements-dev.txt \ + ./qiskit_pkg \ -e . + # Build and install both qiskit and qiskit-terra so that any optionals + # depending on `qiskit` will resolve correctly. displayName: "Install Terra directly" env: SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" diff --git a/.azure/test-macos.yml b/.azure/test-macos.yml index 2b195afbda..cbf2fc8b0e 100644 --- a/.azure/test-macos.yml +++ b/.azure/test-macos.yml @@ -43,7 +43,10 @@ jobs: -c constraints.txt \ -r requirements.txt \ -r requirements-dev.txt \ + ./qiskit_pkg \ -e . + # Build and install both qiskit and qiskit-terra so that any optionals + # depending on `qiskit` will resolve correctly. pip check displayName: 'Install dependencies' env: diff --git a/.azure/test-windows.yml b/.azure/test-windows.yml index 30591a5dad..6ba2e44294 100644 --- a/.azure/test-windows.yml +++ b/.azure/test-windows.yml @@ -42,7 +42,10 @@ jobs: -c constraints.txt \ -r requirements.txt \ -r requirements-dev.txt \ + ./qiskit_pkg \ -e . + # Build and install both qiskit and qiskit-terra so that any optionals + # depending on `qiskit` will resolve correctly. pip check displayName: 'Install dependencies' env: diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index de3485c5fd..221840b4e7 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -42,7 +42,7 @@ jobs: run: python -m pip install -c constraints.txt --upgrade pip setuptools wheel - name: Build and install qiskit-terra - run: python -m pip install -c constraints.txt -e . + run: python -m pip install -c constraints.txt -e . ./qiskit_pkg env: CARGO_INCREMENTAL: 0 RUSTFLAGS: "-Cinstrument-coverage" diff --git a/.github/workflows/slow.yml b/.github/workflows/slow.yml index 62fa9ec19c..528305740d 100644 --- a/.github/workflows/slow.yml +++ b/.github/workflows/slow.yml @@ -19,7 +19,7 @@ jobs: python -m pip install -U pip setuptools wheel python -m pip install -U -r requirements.txt -c constraints.txt python -m pip install -U -r requirements-dev.txt -c constraints.txt - python -m pip install -c constraints.txt -e . + python -m pip install -c constraints.txt -e . ./qiskit_pkg python -m pip install "qiskit-aer" "z3-solver" "cplex" -c constraints.txt env: SETUPTOOLS_ENABLE_FEATURES: "legacy-editable" diff --git a/tox.ini b/tox.ini index fa6d1017d3..0c799d28ba 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,10 @@ envlist = py38, py39, py310, py311, lint-incr isolated_build = true [testenv] -usedevelop = True +# We pretend that we're not actually installing the package, because we need tox to let us have two +# packages ('qiskit' and 'qiskit-terra') under test at the same time. For that, we have to stuff +# them into 'deps'. +skip_install = true install_command = pip install -c{toxinidir}/constraints.txt -U {opts} {packages} setenv = VIRTUAL_ENV={envdir} @@ -15,9 +18,12 @@ setenv = QISKIT_TEST_CAPTURE_STREAMS=1 QISKIT_PARALLEL=FALSE passenv = RAYON_NUM_THREADS, OMP_NUM_THREADS, QISKIT_PARALLEL, RUST_BACKTRACE, SETUPTOOLS_ENABLE_FEATURES, QISKIT_TESTS, QISKIT_IN_PARALLEL -deps = setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.) - -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt +deps = + setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.) + -r{toxinidir}/requirements.txt + -r{toxinidir}/requirements-dev.txt + -e . + -e ./qiskit_pkg commands = stestr run {posargs} @@ -50,6 +56,9 @@ commands = reno lint [testenv:black] +skip_install = true +deps = + -r requirements-dev.txt commands = black {posargs} qiskit test tools examples setup.py qiskit_pkg [testenv:coverage] @@ -57,17 +66,15 @@ basepython = python3 setenv = {[testenv]setenv} PYTHON=coverage3 run --source qiskit --parallel-mode -deps = -r{toxinidir}/requirements.txt - -r{toxinidir}/requirements-dev.txt - -r{toxinidir}/requirements-optional.txt +deps = + {[testenv]deps} + -r{toxinidir}/requirements-optional.txt commands = stestr run {posargs} coverage3 combine coverage3 report [testenv:docs] -# Editable mode breaks macOS: https://github.com/sphinx-doc/sphinx/issues/10943 -usedevelop = False basepython = python3 setenv = {[testenv]setenv} @@ -75,15 +82,9 @@ setenv = RUST_DEBUG=1 # Faster to compile. passenv = {[testenv]passenv}, QISKIT_DOCS_BUILD_TUTORIALS, QISKIT_CELL_TIMEOUT, DOCS_PROD_BUILD deps = - setuptools_rust # This is work around for the bug of tox 3 (see #8606 for more details.) - -r{toxinidir}/requirements-dev.txt + {[testenv]deps} -r{toxinidir}/requirements-optional.txt -r{toxinidir}/requirements-tutorials.txt - # Some optionals depend on Terra. We want to make sure pip satisfies that requirement from a local - # installation, not from PyPI. But Tox normally doesn't install the local installation until - # after `deps` is installed. So, instead, we tell pip to do the local installation at the same - # time as the optionals. See https://github.com/Qiskit/qiskit-terra/pull/9477. - . commands = sphinx-build -W -j auto -T --keep-going -b html docs/ docs/_build/html {posargs}