diff --git a/.github/workflows/Test.yml b/.github/workflows/Test.yml new file mode 100644 index 0000000..ffd1522 --- /dev/null +++ b/.github/workflows/Test.yml @@ -0,0 +1,10 @@ +name: 'Tests' + +on: [push] + +jobs: + call_workflow: + uses: ./.github/workflows/Testbase.yml + with: + python: '3.11' + qt5: 'pyqt5' \ No newline at end of file diff --git a/.github/workflows/Testbase.yml b/.github/workflows/Testbase.yml new file mode 100644 index 0000000..989a2a0 --- /dev/null +++ b/.github/workflows/Testbase.yml @@ -0,0 +1,44 @@ +name: Base + +on: + workflow_call: + inputs: + python: + required: true + type: string + qt5: + required: true + type: string + +jobs: + build: + runs-on: ubuntu-latest + env: + DISPLAY: ':99.0' + QT_DEBUG_PLUGINS: 1 + steps: + - name: Set up Python ${{ inputs.python }} + uses: actions/checkout@v4 + - name: Install dependencies + uses: actions/setup-python@v4 + with: + python-version: ${{ inputs.python }} + - name: Install package + run: | + sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils + python -m pip install --upgrade pip + export QT_DEBUG_PLUGINS=1 + pip install flake8 pytest pytest-cov pytest-qt pytest-xdist pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }} toml + pip install pymodaq pyqt5 + pip install -e . + - name: create local pymodaq folder and setting permissions + run: | + sudo mkdir /etc/.pymodaq + sudo chmod uo+rw /etc/.pymodaq + - name: Linting with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=src/pymodaq/resources/QtDesigner_Ressources,docs + - name: Test with pytest + run: | + pytest -n auto diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index cc1ffb5..69806c5 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -13,19 +13,28 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine toml - - name: Build and publish + pip install hatch hatchling toml twine + - name: Get history and tags for SCM versioning to work + run: | + git branch + git fetch --prune --unshallow + git fetch --depth=1 origin +refs/tags/*:refs/tags/* + hatch version + - name: Build + run: hatch build + - name: Check the build + run: twine check dist/* + - name: publish env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }} + HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel - twine upload dist/* + hatch publish diff --git a/.github/workflows/updater.yml b/.github/workflows/updater.yml new file mode 100644 index 0000000..a80cc91 --- /dev/null +++ b/.github/workflows/updater.yml @@ -0,0 +1,23 @@ +name: GitHub Actions Version Updater + +# Controls when the action will run. +on: + schedule: + # Automatically run at 00:00 on day-of-month 5. + - cron: '0 0 5 * *' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + # [Required] Access token with `workflow` scope. + token: ${{ secrets.WORKFLOW_SECRET }} + + - name: Run GitHub Actions Version Updater + uses: saadmk11/github-actions-version-updater@v0.8.1 + with: + # [Required] Access token with `workflow` scope. + token: ${{ secrets.WORKFLOW_SECRET }} \ No newline at end of file diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 0000000..a0208ee --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,10 @@ +from pathlib import Path +from hatchling.metadata.plugin.interface import MetadataHookInterface +from pymodaq_utils.resources.hatch_build_plugins import update_metadata_from_toml + +here = Path(__file__).absolute().parent + + +class PluginInfoTomlHook(MetadataHookInterface): + def update(self, metadata: dict) -> None: + update_metadata_from_toml(metadata, here) diff --git a/plugin_info.toml b/plugin_info.toml deleted file mode 100644 index 7c5ad51..0000000 --- a/plugin_info.toml +++ /dev/null @@ -1,23 +0,0 @@ -## To modify by developper(s) of the plugin - -[plugin-info] -SHORT_PLUGIN_NAME = 'andor' #for instance daqmx -package-url = 'https://github.com/PyMoDAQ/pymodaq_plugins_andor' #to modify -description = 'Set of PyMoDAQ plugins for Andor Camera (CCD camera using SDK2, SCMOS cameras using SDK3...)' - -author = 'Sébastien Weber' -author-email = 'sebastien.weber@cemes.fr' -license = 'MIT' - -[plugin-install] -#packages required for your plugin: -packages-required = ['pymodaq>=4.0'] -## - -[features] # defines the plugin features contained into this plugin -instruments = true # true if plugin contains instrument classes (else false, notice the lowercase for toml files) -extensions = false # true if plugins contains dashboard extensions -pid_models = false # true if plugins contains pid models -h5exporters = false # true if plugin contains custom h5 file exporters -scanners = false # true if plugin contains custom scan layout (daq_scan extensions) - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9edb929 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,63 @@ +[features] # defines the plugin features contained into this plugin +instruments = true # true if plugin contains instrument classes (else false, notice the lowercase for toml files) +extensions = false # true if plugins contains dashboard extensions +models = false # true if plugins contains pid models +h5exporters = false # true if plugin contains custom h5 file exporters +scanners = false # true if plugin contains custom scan layout (daq_scan extensions) + +[urls] +package-url = 'https://github.com/PyMoDAQ/pymodaq_plugins_andor' + +[project] +name = "pymodaq_plugins_andor" +description = 'Set of PyMoDAQ plugins for Andor Camera (CCD camera using SDK2, SCMOS cameras using SDK3...)' +dependencies = [ + "pymodaq>=5.0.0", + #todo: list here all dependencies your package may have +] + +authors = [ + {name = "Weber Sébastien", email = 'sebastien.weber@cemes.fr'}, + #todo: list here all authors of your plugin +] +maintainers = [ + {name = "Weber Sébastien", email = 'sebastien.weber@cemes.fr'}, + #todo: list here all maintainers of your plugin +] + +# nottodo: leave everything below as is! + +dynamic = ["version", "urls", "entry-points"] +readme = "README.rst" +license = { file="LICENSE" } +requires-python = ">=3.8" + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Topic :: Scientific/Engineering :: Human Machine Interfaces", + "Topic :: Scientific/Engineering :: Visualization", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Software Development :: User Interfaces", +] + +[build-system] +requires = [ + "hatchling>=1.9.0", + "hatch-vcs", "toml", + "pymodaq_utils>=0.0.6", +] +build-backend = "hatchling.build" + +[tool.hatch.metadata.hooks.custom] + +[tool.hatch.version] +source = "vcs" + diff --git a/setup.py b/setup.py deleted file mode 100644 index 7a691fd..0000000 --- a/setup.py +++ /dev/null @@ -1,64 +0,0 @@ -from setuptools import setup, find_packages -import toml - -config = toml.load('./plugin_info.toml') -SHORT_PLUGIN_NAME = config['plugin-info']['SHORT_PLUGIN_NAME'] -PLUGIN_NAME = f"pymodaq_plugins_{SHORT_PLUGIN_NAME}" - - -from pathlib import Path - -with open(str(Path(__file__).parent.joinpath(f'src/{PLUGIN_NAME}/resources/VERSION')), 'r') as fvers: - version = fvers.read().strip() - - -with open('README.rst') as fd: - long_description = fd.read() - -setupOpts = dict( - name=PLUGIN_NAME, - description=config['plugin-info']['description'], - long_description=long_description, - license=config['plugin-info']['license'], - url=config['plugin-info']['package-url'], - author=config['plugin-info']['author'], - author_email=config['plugin-info']['author-email'], - classifiers=[ - "Programming Language :: Python :: 3", - "Development Status :: 5 - Production/Stable", - "Environment :: Other Environment", - "Intended Audience :: Science/Research", - "Topic :: Scientific/Engineering :: Human Machine Interfaces", - "Topic :: Scientific/Engineering :: Visualization", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Software Development :: User Interfaces", - ], ) - - -entrypoints = {} -if 'features' in config: - if config['features'].get('instruments', False): - entrypoints['pymodaq.instruments'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' - if config['features'].get('extensions', False): - entrypoints['pymodaq.extensions'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' - if config['features'].get('pid_models', False): - entrypoints['pymodaq.pid_models'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' - if config['features'].get('h5exporters', False): - entrypoints['pymodaq.h5exporters'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' - if config['features'].get('scanners', False): - entrypoints['pymodaq.scanners'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' -else: - entrypoints['pymodaq.instruments'] = f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}' - -setup( - version=version, - packages=find_packages(where='./src'), - package_dir={'': 'src'}, - include_package_data=True, - entry_points=entrypoints, - install_requires=['toml', ]+config['plugin-install']['packages-required'], - **setupOpts -) - diff --git a/src/pymodaq_plugins_andor/__init__.py b/src/pymodaq_plugins_andor/__init__.py index 8fb6782..5f56a75 100644 --- a/src/pymodaq_plugins_andor/__init__.py +++ b/src/pymodaq_plugins_andor/__init__.py @@ -1,6 +1,13 @@ from pathlib import Path -from pymodaq.utils.logger import set_logger, get_module_name +from pymodaq_utils.logger import set_logger, get_module_name -with open(str(Path(__file__).parent.joinpath('resources/VERSION')), 'r') as fvers: - __version__ = fvers.read().strip() +from pathlib import Path +from .utils import Config +from pymodaq_utils.utils import get_version, PackageNotFoundError + +config = Config() +try: + __version__ = get_version(__package__) +except PackageNotFoundError: + __version__ = '0.0.0dev' \ No newline at end of file diff --git a/src/pymodaq_plugins_andor/daq_move_plugins/daq_move_Shamrock.py b/src/pymodaq_plugins_andor/daq_move_plugins/daq_move_Shamrock.py index 50c1ec0..aa45896 100644 --- a/src/pymodaq_plugins_andor/daq_move_plugins/daq_move_Shamrock.py +++ b/src/pymodaq_plugins_andor/daq_move_plugins/daq_move_Shamrock.py @@ -1,7 +1,7 @@ from easydict import EasyDict as edict from pymodaq.control_modules.move_utility_classes import DAQ_Move_base, comon_parameters_fun, main -from pymodaq.utils.daq_utils import ThreadCommand +from pymodaq_utils.utils import ThreadCommand from pymodaq_plugins_andor.hardware import shamrock_sdk diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCD.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCD.py index 8c113c5..0f30f78 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCD.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCD.py @@ -1,14 +1,17 @@ import numpy as np from qtpy import QtWidgets -from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD -from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock +from pymodaq_utils.logger import set_logger, get_module_name +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val + +from pymodaq_gui.parameter import utils as putils -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val from pymodaq.utils.data import Axis, DataFromPlugins -from pymodaq.utils.parameter import utils as putils from pymodaq.control_modules.viewer_utility_classes import main -from pymodaq.utils.logger import set_logger, get_module_name + +from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD +from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock + logger = set_logger(get_module_name(__file__)) diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCDComposition.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCDComposition.py index 5e8d3ff..421029d 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCDComposition.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockCCDComposition.py @@ -1,14 +1,16 @@ import numpy as np from qtpy import QtWidgets -from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD -from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock +from pymodaq_utils.logger import set_logger, get_module_name +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val + +from pymodaq_gui.parameter import utils as putils -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val from pymodaq.utils.data import Axis, DataFromPlugins, DataToExport -from pymodaq.utils.parameter import utils as putils from pymodaq.control_modules.viewer_utility_classes import main, DAQ_Viewer_base, comon_parameters -from pymodaq.utils.logger import set_logger, get_module_name + +from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorCCD import DAQ_2DViewer_AndorCCD +from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock logger = set_logger(get_module_name(__file__)) diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOS.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOS.py index 17c29e7..f351f8b 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOS.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOS.py @@ -1,15 +1,18 @@ -from ..plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS -from ...daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock import numpy as np -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val -from pymodaq.utils.data import Axis, DataFromPlugins -from pymodaq.utils.parameter import utils as putils from qtpy import QtWidgets + +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val from pymodaq.utils.logger import set_logger, get_module_name -logger = set_logger(get_module_name(__file__)) +from pymodaq_gui.parameter import utils as putils +from pymodaq.utils.data import Axis, DataFromPlugins + +from ..plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS +from ...daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock + +logger = set_logger(get_module_name(__file__)) class DAQ_1DViewer_ShamrockSCMOS(DAQ_2DViewer_AndorSCMOS, DAQ_Move_Shamrock): diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOSComposition.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOSComposition.py index dd98ffd..2bad1ee 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOSComposition.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_1D/daq_1Dviewer_ShamrockSCMOSComposition.py @@ -1,15 +1,18 @@ import numpy as np from qtpy import QtWidgets +from time import perf_counter -from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS -from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val +from pymodaq_utils.logger import set_logger, get_module_name + +from pymodaq_gui.parameter import utils as putils -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val from pymodaq.utils.data import Axis, DataFromPlugins, DataToExport -from pymodaq.utils.parameter import utils as putils from pymodaq.control_modules.viewer_utility_classes import main, DAQ_Viewer_base, comon_parameters -from pymodaq.utils.logger import set_logger, get_module_name -from time import perf_counter + + +from pymodaq_plugins_andor.daq_viewer_plugins.plugins_2D.daq_2Dviewer_AndorSCMOS import DAQ_2DViewer_AndorSCMOS +from pymodaq_plugins_andor.daq_move_plugins.daq_move_Shamrock import DAQ_Move_Shamrock logger = set_logger(get_module_name(__file__)) diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorCCD.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorCCD.py index fff5223..d35074f 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorCCD.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorCCD.py @@ -5,15 +5,15 @@ import platform from qtpy import QtWidgets, QtCore from easydict import EasyDict as edict -from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val +from pymodaq_gui.parameter.utils import iter_children + +from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main from pymodaq.utils.data import DataFromPlugins, Axis, DataToExport -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val -from pymodaq.utils.parameter.utils import iter_children from pymodaq_plugins_andor.hardware.andor_sdk2 import sdk2 - libpath = sdk2.dllpath camera_list = sdk2.AndorSDK.GetCamerasInfo() diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorSCMOS.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorSCMOS.py index 6056b05..a0f77a8 100644 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorSCMOS.py +++ b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_2D/daq_2Dviewer_AndorSCMOS.py @@ -6,11 +6,14 @@ import numpy as np from qtpy import QtWidgets, QtCore +from pymodaq_utils.utils import ThreadCommand, find_dict_in_list_from_key_val, zeros_aligned +from pymodaq_utils.logger import set_logger, get_module_name + +from pymodaq_gui.parameter.utils import iter_children + from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main -from pymodaq.utils.logger import set_logger, get_module_name from pymodaq.utils.data import DataFromPlugins, Axis -from pymodaq.utils.daq_utils import ThreadCommand, find_dict_in_list_from_key_val, zeros_aligned -from pymodaq.utils.parameter.utils import iter_children + arch, plat = platform.architecture() from time import perf_counter diff --git a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_ND/__init__.py b/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_ND/__init__.py deleted file mode 100644 index f02f55f..0000000 --- a/src/pymodaq_plugins_andor/daq_viewer_plugins/plugins_ND/__init__.py +++ /dev/null @@ -1,13 +0,0 @@ -import importlib -from pathlib import Path -from ... import set_logger, get_module_name -logger = set_logger('move_plugins', add_to_console=False) - -for path in Path(__file__).parent.iterdir(): - try: - if '__init__' not in str(path): - importlib.import_module('.' + path.stem, __package__) - except Exception as e: - logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e))) - pass - diff --git a/src/pymodaq_plugins_andor/resources/VERSION b/src/pymodaq_plugins_andor/resources/VERSION deleted file mode 100644 index 45a1b3f..0000000 --- a/src/pymodaq_plugins_andor/resources/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.1.2 diff --git a/src/pymodaq_plugins_andor/utils.py b/src/pymodaq_plugins_andor/utils.py index 1f225ab..4981b95 100644 --- a/src/pymodaq_plugins_andor/utils.py +++ b/src/pymodaq_plugins_andor/utils.py @@ -6,7 +6,7 @@ """ from pathlib import Path -from pymodaq.utils.config import BaseConfig, USER +from pymodaq_utils.config import BaseConfig, USER class Config(BaseConfig):