diff --git a/.github/workflows/test_latest_versions.yml b/.github/workflows/test_latest_versions.yml index 30b7b3c..cc0d062 100644 --- a/.github/workflows/test_latest_versions.yml +++ b/.github/workflows/test_latest_versions.yml @@ -46,11 +46,11 @@ jobs: pip install tox - name: Test using tox environments shell: bash - # One invocation rather than two, so that the extension is compiled once and - # the resulting wheel is installed into both environments. Running `tox -e py` - # and `tox -e mpi` as separate commands would compile it twice. + # One invocation rather than several, so that the extension is compiled once and + # the resulting wheel is installed into each environment. Running them as + # separate commands would compile it once per environment. # - # Not --parallel: the two environments would then race to install the same - # wheel, and the MPI tests want the runner's cores to themselves. + # Not --parallel: the environments would then race to install the same wheel, + # and the MPI tests want the runner's cores to themselves. run: | - tox -e py,mpi + tox -e py,notebook,mpi diff --git a/pyproject.toml b/pyproject.toml index 2d82d7b..039b5d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,10 +31,21 @@ dependencies = [ ] [project.optional-dependencies] -test = [ +basetest = [ "pytest>=8.0", +] +test = [ + "sbd-eigensolver[basetest]", "pytest-mpi>=0.6", ] +nbtest = [ + "sbd-eigensolver[basetest]", + "nbmake>=1.5.0", +] +notebook-dependencies = [ + "qiskit-addon-sqd>=0.13.1", + "pyscf>=2.9", +] [project.urls] Homepage = "https://github.com/Qiskit/sbd-eigensolver-python" diff --git a/tox.ini b/tox.ini index dee9a7c..75068c6 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minversion = 4.4.3 -envlist = py{310,311,312,313,314}, mpi +envlist = py{310,311,312,313,314}{,-notebook}, mpi isolated_build = True [testenv] @@ -52,6 +52,22 @@ setenv = commands = mpirun -n {env:SBD_TEST_NPROCS} pytest --only-mpi {posargs} +# Spelled out with the hyphen outside the braces. Writing this as +# {,py310-,py311-,...}notebook does not work: tox expands numeric ranges in a section +# name before splitting it on braces, so `py314-` parses as `py3` plus the range `14-`, +# which produces junk environment names and never defines py310-notebook and friends -- +# those then silently fall through to [testenv] and run the unit tests instead. Nesting +# braces is not an alternative either; it crashes tox outright. +[testenv:{notebook,py310-notebook,py311-notebook,py312-notebook,py313-notebook,py314-notebook}] +# nbmake runs each notebook with its own directory as the working directory, so the +# relative paths the examples use to reach the vendored data resolve as they would for +# someone running the notebook by hand. +extras = + nbtest + notebook-dependencies +commands = + pytest --nbmake --nbmake-timeout=3000 {posargs} python/examples/ + [testenv:slow] # The reference cases grow by roughly an order of magnitude in determinant count per # row of the upstream tables, and compute time scales worse than linearly in that, so