diff --git a/.github/workflows/spectrumdevice-integration-tests.yml b/.github/workflows/spectrumdevice-integration-tests.yml index 5ce5a3f..8609c8e 100644 --- a/.github/workflows/spectrumdevice-integration-tests.yml +++ b/.github/workflows/spectrumdevice-integration-tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/spectrumdevice-linters.yml b/.github/workflows/spectrumdevice-linters.yml index c5910ad..e2c0500 100644 --- a/.github/workflows/spectrumdevice-linters.yml +++ b/.github/workflows/spectrumdevice-linters.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - python-version: ["3.11"] + python-version: ["3.12"] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/spectrumdevice-unit-tests.yml b/.github/workflows/spectrumdevice-unit-tests.yml index 7a1e8d4..8f191e5 100644 --- a/.github/workflows/spectrumdevice-unit-tests.yml +++ b/.github/workflows/spectrumdevice-unit-tests.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v3 diff --git a/README.md b/README.md index 3644eba..a4ec175 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Limitations section for more information. * [PyPI](https://pypi.org/project/spectrumdevice/) ## Requirements +Python 3.9+ + `spectrumdevice` works with hardware on Windows and Linux. Spectrum do not currently provide a hardware driver for macOS, but `spectrumdevice` provides mock classes for development and testing without hardware, which work on macOS. diff --git a/setup.cfg b/setup.cfg index febe372..1a25da2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -16,10 +16,10 @@ classifiers = Operating System :: POSIX :: Linux Operating System :: Microsoft :: Windows :: Windows 10 Operating System :: MacOS :: MacOS X - Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Topic :: Scientific/Engineering Typing :: Typed project_urls = @@ -48,12 +48,12 @@ test=pytest [options.extras_require] test = - pytest == 6.2.5 + pytest == 7.4.3 dev = - flake8 == 4.0 - flake8-bugbear == 21.9.2 + flake8 == 6.1.0 + flake8-bugbear == 23.9.16 black == 22.3.0 - mypy == 1.3.0 + mypy == 1.6.1 types-setuptools == 67.8.0.0 doc = pdoc == 8.0.1 @@ -61,7 +61,7 @@ examples = matplotlib >= 3.5.0 [mypy] -python_version = 3.11 +python_version = 3.12 warn_unused_configs = True disallow_subclassing_any = True disallow_untyped_calls = True diff --git a/src/spectrumdevice/spectrum_wrapper/error_handler.py b/src/spectrumdevice/spectrum_wrapper/error_handler.py index 01875be..1381a81 100644 --- a/src/spectrumdevice/spectrum_wrapper/error_handler.py +++ b/src/spectrumdevice/spectrum_wrapper/error_handler.py @@ -1,15 +1,13 @@ """Defines an error handling wrapper function for wrapping calls to the Spectrum API.""" - # Christian Baker, King's College London # Copyright (c) 2021 School of Biomedical Engineering & Imaging Sciences, King's College London # Licensed under the MIT. You may obtain a copy at https://opensource.org/licenses/MIT. import logging from functools import wraps +from importlib import resources from typing import Callable, Dict, Any -from pkg_resources import resource_filename - from spectrumdevice.exceptions import SpectrumApiCallFailed, SpectrumFIFOModeHardwareBufferOverrun from spectrum_gmbh.spcerr import ( ERR_OK, @@ -24,10 +22,12 @@ def _parse_errors_table() -> Dict[int, str]: errors: Dict[int, str] = {} - with open(resource_filename(__name__, "spectrum_errors.csv"), "r") as f: - for line in f.readlines(): - cells = line.split(",") - errors[int(cells[2].strip())] = cells[3].strip() + errors_file = resources.files(__package__) / "spectrum_errors.csv" + with resources.as_file(errors_file) as file_path: + with open(file_path) as f: + for line in f.readlines(): + cells = line.split(",") + errors[int(cells[2].strip())] = cells[3].strip() return errors