Skip to content

Commit

Permalink
Remove tweedledum as a core dependency (#8947)
Browse files Browse the repository at this point in the history
* Remove tweedledum as a core dependency

Maintenance on tweedledum has stagnated in recent months, and is no
longer stable enough on our Tier-1 (and other) supported platforms,
especially as further Python versions are released.  This work was
heralded by gh-8738, which contains more context on the change.

* Add tweedledum pylint suppressions

I couldn't get `.pylintrc`'s `ignore{,d}-modules` options to work right
for this, so I just resorted to localised suppressions.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
jakelishman and mergify[bot] authored Oct 20, 2022
1 parent 65851b4 commit 6aad914
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 14 deletions.
5 changes: 3 additions & 2 deletions qiskit/circuit/classicalfunction/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

"""
====================================================================
ClassicalFunction compiler (:mod:`qiskit.circuit.classicalfunction`)
Expand Down Expand Up @@ -97,9 +98,9 @@ def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
"""

from qiskit.utils import optionals as _optionals
from qiskit.utils.optionals import HAS_TWEEDLEDUM

_optionals.HAS_TWEEDLEDUM.require_now("classical oracle creation")
HAS_TWEEDLEDUM.require_now("classical function oracles")

# pylint: disable=wrong-import-position

Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/classicalfunction/boolean_expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from os.path import basename, isfile
from typing import Callable, Optional

from tweedledum import BitVec, BoolFunction
from tweedledum.synthesis import pkrm_synth
from tweedledum import BitVec, BoolFunction # pylint: disable=import-error
from tweedledum.synthesis import pkrm_synth # pylint: disable=import-error

from qiskit.circuit import QuantumCircuit
from .classical_element import ClassicalElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import ast
import _ast

from tweedledum.classical import LogicNetwork
from tweedledum.classical import LogicNetwork # pylint: disable=import-error

from .exceptions import ClassicalFunctionParseError, ClassicalFunctionCompilerTypeError

Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/classicalfunction/classicalfunction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import ast
from typing import Callable, Optional

from tweedledum.classical import simulate
from tweedledum.synthesis import pkrm_synth
from tweedledum.classical import simulate # pylint: disable=import-error
from tweedledum.synthesis import pkrm_synth # pylint: disable=import-error

from qiskit.circuit import QuantumCircuit, QuantumRegister
from qiskit.exceptions import QiskitError
Expand Down
4 changes: 2 additions & 2 deletions qiskit/circuit/classicalfunction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

"""Internal utils for Classical Function Compiler"""

from tweedledum.ir import Qubit
from tweedledum.passes import parity_decomp
from tweedledum.ir import Qubit # pylint: disable=import-error
from tweedledum.passes import parity_decomp # pylint: disable=import-error


from qiskit.circuit import QuantumCircuit
Expand Down
2 changes: 1 addition & 1 deletion qiskit/circuit/library/phase_oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
if synthesizer is None:

def synthesizer(boolean_expression):
from tweedledum.synthesis import pkrm_synth
from tweedledum.synthesis import pkrm_synth # pylint: disable=import-error
from qiskit.circuit.classicalfunction.utils import tweedledum2qiskit

truth_table = boolean_expression._tweedledum_bool_expression.truth_table(
Expand Down
14 changes: 14 additions & 0 deletions releasenotes/notes/remove-tweedledum-0f21ca327a782bc3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
upgrade:
- |
``tweedledum`` has been removed as a core requirement of Qiskit Terra. The
functionality provided (:mod:`qiskit.circuit.classicalfunction`) is still
available, if ``tweedledum`` is installed manually, such as by:
.. code-block:: text
pip install tweedledum
This change was made because ``tweedledum`` development has slowed to the
point of not keeping up with new Python and OS releases, and was blocking
some Qiskit users from installing Qiskit.
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ shared-memory38;python_version<'3.8'
typing-extensions; python_version < '3.8'
singledispatchmethod; python_version < '3.8'

# To be removed as a requirement in Terra 0.23. Tweedledum's wheels are
# hopelessly broken on M1 mac, so we skip the waiting period for that.
tweedledum>=1.1,<2.0; platform_machine != 'arm64' or sys_platform != 'darwin'

# Hack around stevedore being broken by importlib_metadata 5.0; we need to pin
# the requirements rather than the constraints if we need to cut a release
# before stevedore is fixed. `importlib_metadata` is not (currently) a direct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from qiskit.circuit.library.standard_gates import XGate

if HAS_TWEEDLEDUM:
# pylint: disable=import-error
from qiskit.circuit.classicalfunction.utils import tweedledum2qiskit

from tweedledum.ir import Circuit
Expand Down

0 comments on commit 6aad914

Please sign in to comment.