PennyLaneAI / pennylane

PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
https://pennylane.ai
Apache License 2.0
2.29k stars 590 forks source link

Removing `semantic_version` from the list of required packages #5836

Closed PietropaoloFrisoni closed 1 month ago

PietropaoloFrisoni commented 3 months ago

Context: After #5769 and #5754, we can potentially replace all the occurrences of the semantic_version package with packaging in the PennyLane source code, and remove semantic_version from the required Python packages. A similar attempt was performed in #5782, but it was reverted due to some errors in the plugin-matrix tests.

Description of the Change: We replace the remaining occurrences of semantic_version with packaging and remove semantic_version from the required packages in PennyLane. With respect to #5782, now the plugins can be correctly instantiated as:

dev = qml.device("qiskit.aer", wires=2)

dev = qml.device("cirq.simulator", wires=1)

etc.

Specifically, the reason was the usage of packaging to replace semantic_versionin the pennylane/__init__.py file. There was an incompatibility between the workflow of the two packages. Right now, the replacement has been performed to maintain the workflow. For example,

from packaging.specifiers import SpecifierSet, Specifier
from packaging.version import Version

pennylane_requires = ">=0.37.0"
version = "0.38.0.dev0"
>>> Version(version) in SpecifierSet(pennylane_requires)
False
>>> Version(version) in SpecifierSet(pennylane_requires, prereleases=True)
True

Benefits: One package less to keep track of in the dependencies.

Possible Drawbacks: Errors in the plugin-text matrix. If they happen, we'll react as quickly as possible.

Related GitHub Issues: None.

Related Shortcut Stories [sc-64659]

trbromley commented 2 months ago

@PietropaoloFrisoni is there a Shortcut story for this?

PietropaoloFrisoni commented 2 months ago

@trbromley Just added the link to Shortcut

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 99.65%. Comparing base (6715095) to head (c879f34). Report is 1 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #5836 +/- ## ========================================== - Coverage 99.66% 99.65% -0.01% ========================================== Files 430 430 Lines 41638 41350 -288 ========================================== - Hits 41499 41209 -290 - Misses 139 141 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

trbromley commented 2 months ago

@PietropaoloFrisoni is it clear who the reviewers are for this PR?

PietropaoloFrisoni commented 2 months ago

@PietropaoloFrisoni is it clear who the reviewers are for this PR?

No, this PR does not have reviewers assigned yet (but it's a low-priority PR)