Skip to content

Commit

Permalink
Add PyQir as optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
thisac committed Jul 12, 2024
1 parent 08c62c9 commit 56df4d6
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ Tests and coverage can be run using Pytest.
.. note::

For the QIR compiler and loader to work the optional dependency PyQIR (v0.9.0) is required. It can be
installed manually with ``pip install pyqir==0.9.0`` or from PyPI as an extra:
For the QIR compiler and loader to work the PyQIR (v0.9.0) is required. It can be
installed manually with ``pip install pyqir==0.9.0`` or as an optional dependency:

.. code-block:: bash
Expand Down
17 changes: 2 additions & 15 deletions dwave/gate/qir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,11 @@
Contains the QIR compiler, loader and related files and functions.
"""

from typing import Tuple

try:
import pyqir # noqa: F401
except ImportError: # pragma: no cover
pyqir_installed = False
else:
# pyqir==0.9.0 required
from importlib.metadata import version
from packaging.version import parse

pyqir_installed = True

if parse(version("pyqir")) != parse("0.9.0"): # pragma: no cover
raise ImportError(f"PyQIR v0.9.0 required, found {version('pyqir')}")
except ImportError as e: # pragma: no cover
raise ImportError("PyQIR required for using the QIR compiler") from e

if not pyqir_installed: # pragma: no cover
raise ImportError("PyQIR not installed.")

from dwave.gate.qir.compiler import *
from dwave.gate.qir.loader import *
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ requires-python = ">= 3.8"
dependencies = [
"numpy>=1.24.4",
]
[project.optional-dependencies]
qir = [
"pyqir>=0.8.0,<0.10",
]

[project.readme]
file = "README.rst"
Expand Down
5 changes: 5 additions & 0 deletions releasenotes/notes/pyqir-support-a682839ae2ccc0c5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Remove PyQIR version check as it's been added as an optional dependency. A supported
version can now be installed directly with ``pip install dwave-gate[qir]``.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
numpy==1.22.4
# working environment for Python>=3.8,<=3.11
numpy==1.24.4
cython==3.0.6
cgen==2020.1
pyqir==0.9.0

0 comments on commit 56df4d6

Please sign in to comment.