Skip to content

Commit 4bbf1f0

Browse files
authored
Merge pull request #44 from thisac/fix-unpin-requirements
Unpin and update requirements
2 parents 5499b1f + 72ffc9e commit 4bbf1f0

10 files changed

Lines changed: 77 additions & 30 deletions

File tree

README.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.. image:: https://circleci.com/gh/dwavesystems/dwave-gate.svg?style=svg
88
:target: https://circleci.com/gh/dwavesystems/dwave-gate
99

10-
.. image:: https://codecov.io/gh/dwavesystems/dwave-gate/branch/master/graph/badge.svg
10+
.. image:: https://codecov.io/gh/dwavesystems/dwave-gate/branch/main/graph/badge.svg
1111
:target: https://codecov.io/gh/dwavesystems/dwave-gate
1212

1313
dwave-gate
@@ -101,6 +101,15 @@ Tests and coverage can be run using Pytest.
101101
102102
python -m pytest tests/ --cov=dwave.gate
103103
104+
.. note::
105+
106+
For the QIR compiler and loader to work the PyQIR (v0.9.0) is required. It can be
107+
installed manually with ``pip install pyqir==0.9.0`` or as an optional dependency:
108+
109+
.. code-block:: bash
110+
111+
pip install dwave-gate[qir]
112+
104113
.. installation-end-marker
105114
106115
License

docs/README.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.. image:: https://circleci.com/gh/dwavesystems/dwave-gate.svg?style=svg
88
:target: https://circleci.com/gh/dwavesystems/dwave-gate
99

10-
.. image:: https://codecov.io/gh/dwavesystems/dwave-gate/branch/master/graph/badge.svg
10+
.. image:: https://codecov.io/gh/dwavesystems/dwave-gate/branch/main/graph/badge.svg
1111
:target: https://codecov.io/gh/dwavesystems/dwave-gate
1212

1313
dwave-gate
@@ -81,7 +81,7 @@ It can also be installed from source by cloning this GitHub repository and runni
8181
make install
8282
8383
The makefile will also simplify running tests (``make test``), coverage (``make coverage``),
84-
documentation (``make docs```), as well as formatting (``make format``) the code using the `Black
84+
documentation (``make docs``), as well as formatting (``make format``) the code using the `Black
8585
<https://black.readthedocs.io/>`_ formatter (set to a line-length of 100) and `isort
8686
<https://pycqa.github.io/isort/>`_. It's available on both Unix as well as Windows systems, via the
8787
`make.bat` batch file.
@@ -99,7 +99,16 @@ Tests and coverage can be run using Pytest.
9999

100100
.. code-block:: bash
101101
102-
pytest tests/ --cov=dwave.gate
102+
python -m pytest tests/ --cov=dwave.gate
103+
104+
.. note::
105+
106+
For the QIR compiler and loader to work the optional dependency PyQIR (v0.9.0) is required. It can be
107+
installed manually with ``pip install pyqir==0.9.0`` or from PyPI as an extra:
108+
109+
.. code-block:: bash
110+
111+
pip install dwave-gate[qir]
103112
104113
.. installation-end-marker
105114

docs/reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ Reference Documentation
1313
registers
1414
simulator
1515
tools
16+
qir

docs/reference/qir.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
QIR
2+
===
3+
4+
.. automodule:: dwave.gate.qir
5+
:members:
6+
:undoc-members:
7+
:show-inheritance:
8+
9+
Compiler Module
10+
---------------
11+
12+
.. automodule:: dwave.gate.qir.compiler
13+
:members:
14+
:undoc-members:
15+
:show-inheritance:
16+
17+
Instructions Module
18+
-------------------
19+
20+
.. automodule:: dwave.gate.qir.instructions
21+
:members:
22+
:undoc-members:
23+
:show-inheritance:
24+
25+
Loader Module
26+
-------------
27+
28+
.. automodule:: dwave.gate.qir.loader
29+
:members:
30+
:undoc-members:
31+
:show-inheritance:

dwave/gate/qir/__init__.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,11 @@
1717
Contains the QIR compiler, loader and related files and functions.
1818
"""
1919

20-
from typing import Tuple
21-
2220
try:
2321
import pyqir # noqa: F401
24-
except ImportError: # pragma: no cover
25-
pyqir_installed = False
26-
else:
27-
# pyqir>=0.8 required
28-
from importlib.metadata import version
29-
30-
def parse(version: str) -> Tuple[str, str, str]:
31-
"Parse a MAJOR.MINOR.PATCH version string into a tuple."
32-
return tuple(version.split("."))[:3]
33-
34-
pyqir_installed = parse(version("pyqir")) >= parse("0.8.0")
22+
except ImportError as e: # pragma: no cover
23+
raise ImportError("PyQIR required for using the QIR compiler") from e
3524

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

3926
from dwave.gate.qir.compiler import *
4027
from dwave.gate.qir.loader import *

dwave/gate/tools/counters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ def refresh(cls) -> None:
5757
except StopIteration:
5858
cls.length += 1
5959
if cls.length > len(cls._alphanum):
60+
if not cls.id_set:
61+
raise ValueError(
62+
"ID length cannot be longer than number of unique characters available."
63+
)
6064
warnings.warn(
6165
f"Insufficient characters to generate unique ID of length {cls.length} or "
6266
f"longer. Generated batch of {len(cls.id_set)} instead of requested "
6367
f"batch size of {cls.batch} IDs"
6468
)
65-
if not cls.id_set:
66-
raise ValueError(
67-
"ID length cannot be longer than number of unique characters available."
68-
)
6969
break
7070

7171
cls._id_gen = itertools.combinations(cls._alphanum, r=cls.length)

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ requires-python = ">= 3.8"
3434
dependencies = [
3535
"numpy>=1.24.4",
3636
]
37+
[project.optional-dependencies]
38+
qir = [
39+
"pyqir>=0.8.0,<0.10",
40+
]
3741

3842
[project.readme]
3943
file = "README.rst"
@@ -46,7 +50,7 @@ Download = "https://github.com/dwavesystems/dwave-gate/releases"
4650
[tool.cibuildwheel]
4751
build-verbosity = "1"
4852
skip = "pp* *musllinux*"
49-
before-test = "pip install pyqir==0.8.2 && pip install -r {project}/requirements_dev.txt"
53+
before-test = "pip install pyqir==0.9.0 && pip install -r {project}/requirements_dev.txt"
5054
test-command = "pytest {project}/tests"
5155
before-build = "pip install cgen==2020.1 && python {project}/dwave/gate/simulator/operation_generation.py"
5256

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Remove PyQIR version check as it's been added as an optional dependency. A supported
5+
version can now be installed directly with ``pip install dwave-gate[qir]``.

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
# working environment for Python>=3.8,<=3.11
12
numpy==1.24.4
2-
cython==3.0.4
3+
cython==3.0.10
34
cgen==2020.1
4-
pyqir==0.8.2
5+
pyqir==0.9.0

requirements_dev.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pytest==7.2.0
2-
pytest-cov==4.0.0
3-
pytest-mock==3.10.0
4-
typing_extensions==4.4.0
1+
pytest>=7.2.0
2+
pytest-cov>=4.0.0
3+
pytest-mock>=3.10.0
4+
typing_extensions>=4.4.0

0 commit comments

Comments
 (0)