Skip to content

Commit

Permalink
Merge pull request pymeasure#896 from CasperSchippers/py311_support
Browse files Browse the repository at this point in the history
Add support for python 3.11 and drop support for 3.7
  • Loading branch information
CasperSchippers authored Jul 30, 2023
2 parents b726aa9 + 236a982 commit 55e453c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 44 deletions.
25 changes: 25 additions & 0 deletions .github/pymeasure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pymeasure
channels:
- conda-forge
dependencies:
- cloudpickle=1.6.0
- numpy=1.23.4
- pandas=1.5.1
- pint=0.18
- pyqt=5.15.7
- pyqtgraph=0.12.4
- pyserial=3.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=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 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
6 changes: 3 additions & 3 deletions .github/workflows/pymeasure_CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -56,15 +56,15 @@ 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.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- 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
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build:
python: "mambaforge-4.10"

conda:
environment: requirements/pymeasure.yml
environment: .github/pymeasure.yml

sphinx:
configuration: docs/conf.py
Expand Down
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Upcoming version
================
- Dropped support for Python 3.7, added support for Python 3.11

Deprecated features
-------------------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.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
Expand Down
11 changes: 7 additions & 4 deletions docs/dev/adding_instruments/instrument.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ To cite the `Python documentation <https://docs.python.org/3.11/howto/enum.html>
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::

Expand All @@ -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
<InstrMode.HEATING: 1>
<InstrMode.HEATING: 1>
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:
Expand All @@ -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)
<ErrorCode.TEMPSENSOR_FAILURE|COOLER_FAILURE|HEATER_FAILURE: 7>

:code:`IntFlags` are used by many instruments for the purpose just demonstrated.

Expand Down
6 changes: 2 additions & 4 deletions pymeasure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pymeasure/instruments/lakeshore/lakeshore211.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -47,23 +47,23 @@ 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
RANGE_325K = 3
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
Expand Down
25 changes: 0 additions & 25 deletions requirements/pymeasure.yml

This file was deleted.

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ 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
Programming Language :: Python :: 3.11
Topic :: Scientific/Engineering

[options]
Expand Down

0 comments on commit 55e453c

Please sign in to comment.