Skip to content

A one-file change to qiskit_addon_slc/utils/davidson.py would make Windows installs work #84

Description

Environment

  • qiskit-addon-slc version: 0.1.0
  • Python version: 3.12.10
  • Operating system: Windows 11

What is happening and why is it wrong?

qiskit-addon-slc is marked Linux/macOS only because of one dependency, pyscf>=2.10,<3, which has no Windows wheel on PyPI or conda-forge and whose source build is broken on Windows (CMake FindBLAS failure, and further failures past that on bzip2, a missing libxcfun.patch, and 'true' is not recognized as an internal or external command). Every other direct dep already ships a Windows wheel.

But pyscf is barely used here. A repo-wide grep finds it in two files: pyproject.toml (the declaration) and qiskit_addon_slc/utils/davidson.py, which has one import pyscf and one call to pyscf.lib.davidson1, a generic sparse-matrix Davidson eigensolver. That helper has one caller in the package (qiskit_addon_slc/bounds/forward.py:187). Replacing that one call with a scipy equivalent (already a transitive dep via qiskit) drops pyscf entirely and lets qiskit-addon-slc install cleanly on Windows alongside Linux and macOS.

How can we reproduce the issue?

py -3.12 -m venv venv
.\venv\Scripts\Activate.ps1
pip install qiskit-addon-slc

Traceback

Captured with MSVC Build Tools 2022 + CMake 3.29 already installed (same failure on a clean machine too). The from-source pyscf build failure:

Collecting pyscf<3,>=2.10 (from qiskit-addon-slc)
  ...
  Building wheel for pyscf (pyproject.toml): started
  Building wheel for pyscf (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error

  × Building wheel for pyscf (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [output]
      ...
      -- Looking for sgemm_ - not found
      ...
      -- Could NOT find BLAS (missing: BLAS_LIBRARIES)
      CMake Error at CMakeLists.txt:79 (message):
        A required library with BLAS API not found.

      -- Configuring incomplete, errors occurred!
      error: command 'cmake.EXE' failed with exit code 1

ERROR: Failed building wheel for pyscf
Failed to build pyscf
ERROR: Failed to build installable wheels for some pyproject.toml based projects (pyscf)

The --no-deps import failure, which exposes where the actual coupling lives:

File ".../qiskit_addon_slc/bounds/__init__.py", line 35, in <module>
    from .backward import compute_backward_bounds
File ".../qiskit_addon_slc/bounds/backward.py", line 36, in <module>
    from ..utils import remove_measure
File ".../qiskit_addon_slc/utils/__init__.py", line 44, in <module>
    from .davidson import get_extremal_eigenvalue
File ".../qiskit_addon_slc/utils/davidson.py", line 22, in <module>
    import pyscf
ModuleNotFoundError: No module named 'pyscf'

Any suggestions?

Replace pyscf.lib.davidson1 with scipy.sparse.linalg.lobpcg in qiskit_addon_slc/utils/davidson.py. It is a drop-in: same problem (smallest eigenvalue of a sparse Hermitian matrix with a diagonal preconditioner), same shape of API (callable A @ v, initial guess x0, preconditioner, tolerance, max iterations). scipy is already a transitive dep of qiskit, so no new requirement is introduced. The signature of get_extremal_eigenvalue stays unchanged, so bounds/forward.py:187 does not change at all. After this, pyscf can be removed from pyproject.toml entirely, the Linux/macOS-only badge and classifiers can be dropped, and Windows users can pip install qiskit-addon-slc like everyone else.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions