diff --git a/.pylintrc b/.pylintrc index 982d3901d6c..ecd788f66f5 100644 --- a/.pylintrc +++ b/.pylintrc @@ -2,7 +2,7 @@ # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code -extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag +extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag [TYPECHECK] @@ -10,12 +10,12 @@ extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy +ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). This supports can work # with qualified names. -ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar +ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar [MESSAGES CONTROL] diff --git a/doc/development/guide/installation.rst b/doc/development/guide/installation.rst index 3cd3d4540a5..24fd5c44d3e 100644 --- a/doc/development/guide/installation.rst +++ b/doc/development/guide/installation.rst @@ -19,6 +19,7 @@ be installed alongside PennyLane: * `appdirs `_ * `semantic-version `_ >= 2.7 * `autoray `__ >= 0.6.11 +* `packaging `_ The following Python packages are optional: diff --git a/doc/releases/changelog-dev.md b/doc/releases/changelog-dev.md index 6409d734cc0..649d1d34801 100644 --- a/doc/releases/changelog-dev.md +++ b/doc/releases/changelog-dev.md @@ -9,6 +9,9 @@

Improvements 🛠

+* Added `packaging` in the required list of packages. + [(#5769)](https://github.com/PennyLaneAI/pennylane/pull/5769). + * Logging now allows for an easier opt-in across the stack, and also extends control support to `catalyst`. [(#5528)](https://github.com/PennyLaneAI/pennylane/pull/5528). diff --git a/doc/requirements.txt b/doc/requirements.txt index 8c7e0927da3..b86201fb9df 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -10,6 +10,7 @@ m2r2 numpy pygments-github-lexers semantic_version==2.10 +packaging scipy docutils==0.16 sphinx~=3.5.0; python_version < "3.10" diff --git a/pennylane/__init__.py b/pennylane/__init__.py index 7524882e84a..80419832ae0 100644 --- a/pennylane/__init__.py +++ b/pennylane/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2018-2021 Xanadu Quantum Technologies Inc. +# Copyright 2018-2024 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import numpy as _np + from semantic_version import SimpleSpec, Version from pennylane.boolean_fn import BooleanFn diff --git a/pennylane/compiler/compiler.py b/pennylane/compiler/compiler.py index 816705bf35c..95a08bf1be8 100644 --- a/pennylane/compiler/compiler.py +++ b/pennylane/compiler/compiler.py @@ -20,7 +20,7 @@ from sys import version_info from typing import List, Optional -from semantic_version import Version +from packaging.version import Version PL_CATALYST_MIN_VERSION = Version("0.6.0") diff --git a/pennylane/devices/default_qubit_tf.py b/pennylane/devices/default_qubit_tf.py index efc2224af6f..48d7c60b788 100644 --- a/pennylane/devices/default_qubit_tf.py +++ b/pennylane/devices/default_qubit_tf.py @@ -1,4 +1,4 @@ -# Copyright 2018-2021 Xanadu Quantum Technologies Inc. +# Copyright 2018-2024 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ import itertools import numpy as np -import semantic_version +from packaging.version import Version import pennylane as qml @@ -29,7 +29,7 @@ from tensorflow.python.framework.errors_impl import InvalidArgumentError - SUPPORTS_APPLY_OPS = semantic_version.match(">=2.3.0", tf.__version__) + SUPPORTS_APPLY_OPS = Version(tf.__version__) >= Version("2.3.0") except ImportError as e: # pragma: no cover raise ImportError("default.qubit.tf device requires TensorFlow>=2.0") from e diff --git a/pennylane/devices/default_qubit_torch.py b/pennylane/devices/default_qubit_torch.py index 29e8455f66f..e0bb276e513 100644 --- a/pennylane/devices/default_qubit_torch.py +++ b/pennylane/devices/default_qubit_torch.py @@ -1,4 +1,4 @@ -# Copyright 2018-2021 Xanadu Quantum Technologies Inc. +# Copyright 2018-2024 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,12 +18,14 @@ import logging import warnings -import semantic_version +from packaging.version import Version try: import torch - VERSION_SUPPORT = semantic_version.match(">=1.8.1", torch.__version__) + VERSION_SUPPORT = Version(torch.__version__) >= Version( + "1.8.1", + ) if not VERSION_SUPPORT: # pragma: no cover raise ImportError("default.qubit.torch device requires Torch>=1.8.1") diff --git a/pennylane/qnn/keras.py b/pennylane/qnn/keras.py index 675db560f0b..8a6ec4084a1 100644 --- a/pennylane/qnn/keras.py +++ b/pennylane/qnn/keras.py @@ -1,4 +1,4 @@ -# Copyright 2018-2021 Xanadu Quantum Technologies Inc. +# Copyright 2018-2024 Xanadu Quantum Technologies Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ from collections.abc import Iterable from typing import Optional, Text -from semantic_version import Version +from packaging.version import Version try: import tensorflow as tf diff --git a/requirements-ci.txt b/requirements-ci.txt index 932820a266d..102f6521586 100644 --- a/requirements-ci.txt +++ b/requirements-ci.txt @@ -8,6 +8,7 @@ autograd toml appdirs semantic_version +packaging autoray>=0.6.1,<0.6.10 matplotlib requests diff --git a/requirements.txt b/requirements.txt index 869e241616a..35ffc8d4378 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,6 +9,7 @@ autograd~=1.4 toml~=0.10 appdirs~=1.4 semantic_version~=2.10 +packaging autoray>=0.6.11 matplotlib~=3.5 opt_einsum~=3.3 diff --git a/setup.py b/setup.py index 892e962ec14..6466a02abce 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -# Copyright 2018-2020 Xanadu Quantum Technologies Inc. +# Copyright 2018-2024 Xanadu Quantum Technologies Inc. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,6 +34,7 @@ "pennylane-lightning>=0.36", "requests", "typing_extensions", + "packaging", ] info = { diff --git a/tests/.pylintrc b/tests/.pylintrc index e19ecaaf4dd..a60dace1845 100644 --- a/tests/.pylintrc +++ b/tests/.pylintrc @@ -2,7 +2,7 @@ # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code -extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag +extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag [TYPECHECK] @@ -10,12 +10,12 @@ extension-pkg-whitelist=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd # (useful for modules/projects where namespaces are manipulated during runtime # and thus existing member attributes cannot be deduced by static analysis. It # supports qualified module names, as well as Unix pattern matching. -ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy +ignored-modules=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy # List of classes names for which member attributes should not be checked # (useful for classes with attributes dynamically set). This supports can work # with qualified names. -ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar +ignored-classes=numpy,scipy,autograd,toml,appdir,autograd.numpy,autograd.numpy.linalg,autograd.numpy.builtins,semantic_version,packaging,torch,tensorflow,tensorflow.contrib,tensorflow.contrib.eager,LazyLoader,networkx,networkx.dag,math,pennylane.numpy,pennylane.numpy.random,pennylane.numpy.linalg,pennylane.numpy.builtins,pennylane.operation,rustworkx,kahypar [MESSAGES CONTROL]