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
This commit is contained in:
Jake Lishman 2023-11-15 15:42:19 +01:00 committed by GitHub
parent 258fb23448
commit f7f6cb1150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 23 deletions

View File

@ -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"

View File

@ -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"

View File

@ -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:

View File

@ -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:

View File

@ -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"

View File

@ -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"

33
tox.ini
View File

@ -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}