From 34cddf60ee4e5b9326be93759554bf645cac8e0e Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Sun, 16 Apr 2023 13:49:53 +0200 Subject: [PATCH 01/12] Add support for python 3.11 --- .github/workflows/pymeasure_CI.yml | 2 +- README.rst | 2 +- setup.cfg | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pymeasure_CI.yml b/.github/workflows/pymeasure_CI.yml index 01ec363108..9fca5e6d0b 100644 --- a/.github/workflows/pymeasure_CI.yml +++ b/.github/workflows/pymeasure_CI.yml @@ -56,7 +56,7 @@ jobs: fail-fast: true matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.7", "3.8", "3.9", "3.10"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 with: diff --git a/README.rst b/README.rst index 8acd1de3f1..1c0fed66b9 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ PyMeasure is currently under active development, so please report any issues you .. _Issues page: https://github.com/pymeasure/pymeasure/issues -PyMeasure runs on Python 3.7-3.10, and is tested with continous-integration on Linux, macOS, and Windows. +PyMeasure runs on Python 3.7-3.11, and is tested with continous-integration on Linux, macOS, and Windows. .. image:: https://github.com/pymeasure/pymeasure/workflows/Pymeasure%20CI/badge.svg :target: https://github.com/pymeasure/pymeasure/actions diff --git a/setup.cfg b/setup.cfg index 34fe5b6a68..acafafc6cd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,6 +22,7 @@ classifiers = Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Topic :: Scientific/Engineering [options] From 3d920f580346f601c36ebd1554a7f400e7d46260 Mon Sep 17 00:00:00 2001 From: Christoph Buchner Date: Mon, 17 Apr 2023 22:36:47 +0200 Subject: [PATCH 02/12] Use versions that have py311 available. Unfortunately, there are no pandas and numpy versions that support 3.7 _and_ 3.11 --- requirements/pymeasure.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index 3028447c17..8e76fc9a7e 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -3,19 +3,19 @@ channels: - conda-forge dependencies: - cloudpickle=1.6.0 - - numpy=1.21.4 - - pandas=1.3.5 + - numpy=1.23.4 # does not support py37 anymore + - pandas=1.5.1 # does not support py37 anymore - pint=0.18 - pyqt=5.15.7 - pyqtgraph=0.12.4 - pyserial=3.4 - - pyvisa=1.11.3 - - pyzmq=22.3.0 - - qt=5.15.4 + - pyvisa=1.12.0 + - pyzmq=24.0.1 + - qt=5.15.6 # Development dependencies below - pytest-qt=4.2.0 - pytest-runner=5.2 - - pytest=6.2.5 + - pytest=7.2.0 - flake8=5.0.4 # can be bumped to v6 when support for python 3.7 is dropped - setuptools_scm # don't pin, to get newest features - sphinx=4.3.1 From 61d1a885ee504a5210a2e758ed380c913c1f9150 Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Wed, 19 Jul 2023 22:34:10 +0200 Subject: [PATCH 03/12] Remove python 3.7 support --- .github/workflows/pymeasure_CI.yml | 2 +- CHANGES.rst | 1 + README.rst | 2 +- pymeasure/__init__.py | 6 ++---- requirements/pymeasure.yml | 2 +- setup.cfg | 1 - 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pymeasure_CI.yml b/.github/workflows/pymeasure_CI.yml index 9fca5e6d0b..68e7f58408 100644 --- a/.github/workflows/pymeasure_CI.yml +++ b/.github/workflows/pymeasure_CI.yml @@ -56,7 +56,7 @@ jobs: fail-fast: true matrix: os: ["ubuntu-latest", "macos-latest", "windows-latest"] - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11"] steps: - uses: actions/checkout@v3 with: diff --git a/CHANGES.rst b/CHANGES.rst index 5a63743ebd..bbdbbcc17f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,5 +1,6 @@ Upcoming version ================ +- Dropped support for Python 3.7, adding support for Python 3.11 Deprecated features ------------------- diff --git a/README.rst b/README.rst index 1c0fed66b9..a55c710591 100644 --- a/README.rst +++ b/README.rst @@ -10,7 +10,7 @@ PyMeasure is currently under active development, so please report any issues you .. _Issues page: https://github.com/pymeasure/pymeasure/issues -PyMeasure runs on Python 3.7-3.11, and is tested with continous-integration on Linux, macOS, and Windows. +PyMeasure runs on Python 3.8-3.11, and is tested with continous-integration on Linux, macOS, and Windows. .. image:: https://github.com/pymeasure/pymeasure/workflows/Pymeasure%20CI/badge.svg :target: https://github.com/pymeasure/pymeasure/actions diff --git a/pymeasure/__init__.py b/pymeasure/__init__.py index 562f54d78e..284da786fa 100644 --- a/pymeasure/__init__.py +++ b/pymeasure/__init__.py @@ -36,10 +36,8 @@ del setuptools_scm except (ImportError, LookupError): # Setuptools_scm was not found, or it could not find a version, so use installation metadata. - try: - from importlib.metadata import version, PackageNotFoundError - except ImportError: # TODO: Remove this when Python 3.7 support is dropped - from importlib_metadata import version, PackageNotFoundError + from importlib.metadata import version, PackageNotFoundError + try: __version__ = version("pymeasure") # Alternatively, if the current approach is too slow, we could add diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index 8e76fc9a7e..c9d02a2295 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -16,7 +16,7 @@ dependencies: - pytest-qt=4.2.0 - pytest-runner=5.2 - pytest=7.2.0 - - flake8=5.0.4 # can be bumped to v6 when support for python 3.7 is dropped + - flake8=6.0.0 - setuptools_scm # don't pin, to get newest features - sphinx=4.3.1 - sphinx_rtd_theme=1.0.0 diff --git a/setup.cfg b/setup.cfg index acafafc6cd..fba95e5f29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -18,7 +18,6 @@ classifiers = Operating System :: POSIX Operating System :: Unix Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 From 756bc459a20a03e91c748f2b9a61069f3b165eae Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Wed, 19 Jul 2023 22:40:10 +0200 Subject: [PATCH 04/12] Remove py37 comment --- requirements/pymeasure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index c9d02a2295..e3d1adabd9 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -3,8 +3,8 @@ channels: - conda-forge dependencies: - cloudpickle=1.6.0 - - numpy=1.23.4 # does not support py37 anymore - - pandas=1.5.1 # does not support py37 anymore + - numpy=1.23.4 + - pandas=1.5.1 - pint=0.18 - pyqt=5.15.7 - pyqtgraph=0.12.4 From a1efddc4cc8225b8479517caa682c0be3163097f Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Wed, 19 Jul 2023 23:04:24 +0200 Subject: [PATCH 05/12] Update sphinx version to resolve docs building --- requirements/pymeasure.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index e3d1adabd9..0296585888 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -18,8 +18,8 @@ dependencies: - pytest=7.2.0 - flake8=6.0.0 - setuptools_scm # don't pin, to get newest features - - sphinx=4.3.1 - - sphinx_rtd_theme=1.0.0 + - sphinx=6.2.1 + - sphinx_rtd_theme=1.2.2 - pip # don't pin, to gain newest conda compatibility fixes - pip: - pyvisa-sim==0.4.0 From c1ee7ea25ce8eaad6c986d272d45a71c996ea7ca Mon Sep 17 00:00:00 2001 From: Christoph Buchner Date: Thu, 20 Jul 2023 08:42:54 +0200 Subject: [PATCH 06/12] Lower Sphinx version Latest does not work together with sphinx_rtd_theme because a dependency problem with docutils. --- requirements/pymeasure.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index 0296585888..cbc84dde1a 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -18,7 +18,7 @@ dependencies: - pytest=7.2.0 - flake8=6.0.0 - setuptools_scm # don't pin, to get newest features - - sphinx=6.2.1 + - sphinx=5.3.0 - sphinx_rtd_theme=1.2.2 - pip # don't pin, to gain newest conda compatibility fixes - pip: From 0e370b17afc1955ef81395720f739a94814a1d29 Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Fri, 21 Jul 2023 00:12:30 +0200 Subject: [PATCH 07/12] Upgrade pyvisa-sim version and acquire from conda instead of pypi --- requirements/pymeasure.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index cbc84dde1a..6dbc689bff 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -16,10 +16,9 @@ dependencies: - pytest-qt=4.2.0 - pytest-runner=5.2 - pytest=7.2.0 + - pyvisa-sim==0.5.1 - flake8=6.0.0 - setuptools_scm # don't pin, to get newest features - sphinx=5.3.0 - sphinx_rtd_theme=1.2.2 - pip # don't pin, to gain newest conda compatibility fixes - - pip: - - pyvisa-sim==0.4.0 From 85c3226c1377d12a95bd4bf6c31a1855d7fa32e2 Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Mon, 24 Jul 2023 22:45:55 +0200 Subject: [PATCH 08/12] Replace incorrect IntFlag by IntEnum --- pymeasure/instruments/lakeshore/lakeshore211.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pymeasure/instruments/lakeshore/lakeshore211.py b/pymeasure/instruments/lakeshore/lakeshore211.py index 3269466183..89cf0d1dd3 100644 --- a/pymeasure/instruments/lakeshore/lakeshore211.py +++ b/pymeasure/instruments/lakeshore/lakeshore211.py @@ -27,7 +27,7 @@ from pymeasure.instruments import Instrument from pymeasure.instruments.validators import strict_discrete_set from pyvisa.constants import Parity -from enum import IntFlag +from enum import IntEnum log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) @@ -47,11 +47,11 @@ class LakeShore211(Instrument): """ - class AnalogMode(IntFlag): + class AnalogMode(IntEnum): VOLTAGE = 0 CURRENT = 1 - class AnalogRange(IntFlag): + class AnalogRange(IntEnum): RANGE_20K = 0 RANGE_100K = 1 RANGE_200K = 2 @@ -59,11 +59,11 @@ class AnalogRange(IntFlag): RANGE_475K = 4 RANGE_1000K = 5 - class RelayNumber(IntFlag): + class RelayNumber(IntEnum): RELAY_ONE = 1 RELAY_TWO = 2 - class RelayMode(IntFlag): + class RelayMode(IntEnum): OFF = 0 ON = 1 ALARMS = 2 From ab7bea04b8160c44242b19d50e4d8382ce1ffc13 Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Mon, 24 Jul 2023 23:07:36 +0200 Subject: [PATCH 09/12] Update doctest to work on python 3.8 through python 3.11 Including note on changed enum printing behaviour in python 3.11 --- docs/dev/adding_instruments/instrument.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/dev/adding_instruments/instrument.rst b/docs/dev/adding_instruments/instrument.rst index 0d43640b3a..86f53e3229 100644 --- a/docs/dev/adding_instruments/instrument.rst +++ b/docs/dev/adding_instruments/instrument.rst @@ -155,6 +155,7 @@ To cite the `Python documentation As our signal values are often integers, the most appropriate enum types are :code:`IntEnum` and :code:`IntFlag`. :code:`IntEnum` is the same as :code:`Enum`, but its members are also integers and can be used anywhere that an integer can be used (so their use for composing commands is transparent), but logic/code they appear in is much more legible. +Note that starting from Python version 3.11, the printed format of the :code:`IntEnum` and :code:`IntFlag` has been changed to return numeric value; however, the symbolic name can be obtained by printing its :code:`repr` or the :code:`.name` property, or returning the value in a REPL. .. doctest:: @@ -169,10 +170,12 @@ As our signal values are often integers, the most appropriate enum types are :co >>> if current_mode == InstrMode.WAITING: ... print('Idle') ... else: - ... print(current_mode) + ... current_mode + ... print(repr(current_mode)) ... print(f'Mode value: {current_mode}') ... - InstrMode.HEATING + + Mode value: 1 :code:`IntFlag` has the added benefit that it supports bitwise operators and combinations, and as such is a good fit for status bitmasks or error codes that can represent multiple values: @@ -188,8 +191,8 @@ As our signal values are often integers, the most appropriate enum types are :co ... OK = 0 ... >>> received_from_device = 7 - >>> print(ErrorCode(received_from_device)) - ErrorCode.TEMPSENSOR_FAILURE|COOLER_FAILURE|HEATER_FAILURE + >>> ErrorCode(received_from_device) + :code:`IntFlags` are used by many instruments for the purpose just demonstrated. From 1d74070ef48716f22e12ebf8ccd6f482c222eb6f Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Mon, 24 Jul 2023 23:14:02 +0200 Subject: [PATCH 10/12] Comment out pip, c.f. suggestion by @bmoneke --- requirements/pymeasure.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements/pymeasure.yml b/requirements/pymeasure.yml index 6dbc689bff..51f300dc4d 100644 --- a/requirements/pymeasure.yml +++ b/requirements/pymeasure.yml @@ -21,4 +21,5 @@ dependencies: - setuptools_scm # don't pin, to get newest features - sphinx=5.3.0 - sphinx_rtd_theme=1.2.2 - - pip # don't pin, to gain newest conda compatibility fixes +# pip is currently not needed, but the recommended tool when packages that are unavailable on conda are required +# - pip # don't pin, to gain newest conda compatibility fixes From 13865aff4d9dd8b131fe78a2119721c2f03f982e Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Mon, 24 Jul 2023 23:19:32 +0200 Subject: [PATCH 11/12] Move requirements file to .github dir, c.f. suggestion by @mcdo0486 --- {requirements => .github}/pymeasure.yml | 0 .github/workflows/pymeasure_CI.yml | 4 ++-- .readthedocs.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename {requirements => .github}/pymeasure.yml (100%) diff --git a/requirements/pymeasure.yml b/.github/pymeasure.yml similarity index 100% rename from requirements/pymeasure.yml rename to .github/pymeasure.yml diff --git a/.github/workflows/pymeasure_CI.yml b/.github/workflows/pymeasure_CI.yml index 68e7f58408..b0e4b58bb9 100644 --- a/.github/workflows/pymeasure_CI.yml +++ b/.github/workflows/pymeasure_CI.yml @@ -20,7 +20,7 @@ jobs: - name: Install pymeasure requirements uses: mamba-org/setup-micromamba@v1 with: - environment-file: requirements/pymeasure.yml + environment-file: .github/pymeasure.yml cache-environment-key: pylatest-ubuntu-latest-mamba-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} cache-downloads: false - name: Python and Mamba version @@ -64,7 +64,7 @@ jobs: - name: Install pymeasure requirements uses: mamba-org/setup-micromamba@v1 with: - environment-file: requirements/pymeasure.yml + environment-file: .github/pymeasure.yml create-args: python=${{ matrix.python-version }} cache-environment-key: py${{ matrix.python-version }}-${{ matrix.os }}-mamba-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }} cache-downloads: false diff --git a/.readthedocs.yml b/.readthedocs.yml index 40846a1641..535724d2a9 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -6,7 +6,7 @@ build: python: "mambaforge-4.10" conda: - environment: requirements/pymeasure.yml + environment: .github/pymeasure.yml sphinx: configuration: docs/conf.py From 236a982e29926e10f5a5d1bdc0e58baa15716ac6 Mon Sep 17 00:00:00 2001 From: Casper Schippers Date: Sat, 29 Jul 2023 16:25:44 +0200 Subject: [PATCH 12/12] Update CHANGES.rst Co-authored-by: Benedikt Moneke <67148916+bmoneke@users.noreply.github.com> --- CHANGES.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index bbdbbcc17f..ca18594194 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,6 @@ Upcoming version ================ -- Dropped support for Python 3.7, adding support for Python 3.11 +- Dropped support for Python 3.7, added support for Python 3.11 Deprecated features -------------------