Skip to content

Commit

Permalink
Ensure metapackage is installed during CI and tox (Qiskit#11119)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jakelishman authored Nov 15, 2023
1 parent 258fb23 commit f7f6cb1
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .azure/lint-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
15 changes: 10 additions & 5 deletions .azure/test-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}:
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions .azure/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions .azure/test-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
33 changes: 17 additions & 16 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}

Expand Down Expand Up @@ -50,40 +56,35 @@ 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]
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}
QISKIT_SUPPRESS_PACKAGING_WARNINGS=Y
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}

Expand Down

0 comments on commit f7f6cb1

Please sign in to comment.