From 79f3377ddd2a2c4ba9a259693769ac9c9f72e795 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Weber?= Date: Wed, 10 Feb 2021 22:33:11 +0100 Subject: [PATCH] src layout and autopublih on release --- .github/workflows/python-publish.yml | 31 +++++ README.rst | 52 +++++++-- plugin_info.py | 11 -- plugin_info.toml | 15 +++ pymodaq_plugins_daqmx/version.py | 106 ------------------ setup.py | 30 ++--- src/pymodaq_plugins_daqmx/VERSION | 1 + .../pymodaq_plugins_daqmx}/__init__.py | 0 .../daq_move_plugins/__init__.py | 0 .../daq_move_plugins/daq_move_DAQmx.py | 0 .../daq_viewer_plugins/__init__.py | 0 .../daq_viewer_plugins/plugins_0D/__init__.py | 0 .../plugins_0D/daq_0Dviewer_DAQmx.py | 0 .../daq_viewer_plugins/plugins_1D/__init__.py | 0 .../plugins_1D/daq_1Dviewer_DAQmx.py | 0 .../daq_viewer_plugins/plugins_2D/__init__.py | 0 .../daq_viewer_plugins/plugins_ND/__init__.py | 0 .../hardware/__init__.py | 0 .../hardware/national_instruments/__init__.py | 0 .../national_instruments/daq_NIDAQmx.py | 0 .../hardware/national_instruments/daqmx.py | 0 21 files changed, 103 insertions(+), 143 deletions(-) create mode 100644 .github/workflows/python-publish.yml delete mode 100644 plugin_info.py create mode 100644 plugin_info.toml delete mode 100644 pymodaq_plugins_daqmx/version.py create mode 100644 src/pymodaq_plugins_daqmx/VERSION rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_move_plugins/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_move_plugins/daq_move_DAQmx.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_0D/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_0D/daq_0Dviewer_DAQmx.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_1D/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_1D/daq_1Dviewer_DAQmx.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_2D/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/daq_viewer_plugins/plugins_ND/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/hardware/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/hardware/national_instruments/__init__.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/hardware/national_instruments/daq_NIDAQmx.py (100%) rename {pymodaq_plugins_daqmx => src/pymodaq_plugins_daqmx}/hardware/national_instruments/daqmx.py (100%) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 0000000..cc1ffb5 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,31 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Upload Python Package + +on: + release: + types: [created] + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + 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 + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* diff --git a/README.rst b/README.rst index 0ee3125..01f6d49 100644 --- a/README.rst +++ b/README.rst @@ -1,12 +1,48 @@ -# PyMoDAQ National Instrument DAQmx Plugin +pymodaq_plugins_daqmx (National Instrument DAQmx) +################################################# -PyMoDAQ, Modular Data Acquisition with Python, is a set of **python** modules used to perform automated -measurements. This repository contains the NI DAQmx plugins compatible with PyMoDAQ to generate and acquire -signals using National Instruments acquisition cards +.. image:: https://img.shields.io/pypi/v/pymodaq_plugins_daqmx.svg + :target: https://pypi.org/project/pymodaq_plugins_daqmx/ + :alt: Latest Version -PyMoDAQ repo: https://github.com/CEMES-CNRS -Plugin repo: https://github.com/CEMES-CNRS/pymodaq_plugins_daqmx +.. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest + :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest + :alt: Documentation Status + +.. image:: https://github.com/CEMES-CNRS/pymodaq_plugins_daqmx/workflows/Upload%20Python%20Package/badge.svg + :target: https://github.com/CEMES-CNRS/pymodaq_plugins_daqmx + +Plugin devoted to the National Instrument signal acquisition and generation using the NiDAQmx library. Includes an +actuator plugin for signal generation, a 1D viewer plugin for data acquisition as a function of time and a 0D viewer +plugin for quick time averaging acquisition + +Authors +======= + +* Sébastien J. Weber + +Contributors +============ + +* Amelie Jarnac + +Instruments +=========== +Below is the list of instruments included in this plugin + +Actuators ++++++++++ + +* **DAQmx**: Analog output DC, Sinus, Ramp... + +Viewer0D +++++++++ + +* **DAQmx**: Analog acquisition, Counting + +Viewer1D +++++++++ + +* **DAQmx**: Analog acquisition -Documentation: http://pymodaq.cnrs.fr/ -For an exhaustive list of the available plugins, see https://github.com/CEMES-CNRS/pymodaq_plugin_manager/blob/main/pymodaq_plugin_manager/doc/PluginList.md diff --git a/plugin_info.py b/plugin_info.py deleted file mode 100644 index c359ffa..0000000 --- a/plugin_info.py +++ /dev/null @@ -1,11 +0,0 @@ -## To modify by developper(s) of the plugin -SHORT_PLUGIN_NAME = 'daqmx' -package_url = 'https://github.com/CEMES-CNRS/pymodaq_plugins_daqmx' -description = 'Hardware plugins for PyMoDAQ using the NiDAQmx framework (pydaqmx wrapper)' - -author = 'Sébastien Weber' -author_email = 'sebastien.weber@cemes.fr' - -#packages required for your plugin: -packages_required = ['pydaqmx',] -## \ No newline at end of file diff --git a/plugin_info.toml b/plugin_info.toml new file mode 100644 index 0000000..2a61c00 --- /dev/null +++ b/plugin_info.toml @@ -0,0 +1,15 @@ +## To modify by developper(s) of the plugin + +[plugin-info] +SHORT_PLUGIN_NAME = 'daqmx' #for instance daqmx +package-url = 'https://github.com/CEMES-CNRS/pymodaq_plugins_daqmx' #to modify +description = 'Hardware plugins for PyMoDAQ using the NiDAQmx framework (pydaqmx wrapper)' + +author = 'Sébastien Weber' +author-email = 'sebastien.weber@cemes.fr' +license = 'MIT' + +[plugin-install] +#packages required for your plugin: +packages-required = ['pydaqmx'] +## \ No newline at end of file diff --git a/pymodaq_plugins_daqmx/version.py b/pymodaq_plugins_daqmx/version.py deleted file mode 100644 index 4838db5..0000000 --- a/pymodaq_plugins_daqmx/version.py +++ /dev/null @@ -1,106 +0,0 @@ -""" -Current pymodaq_plugins_daqmx plugin version constant plus version pretty-print method. -This functionality is contained in its own module to prevent circular import -problems with ``__init__.py`` (which is loaded by setup.py during installation, -which in turn needs access to this version information.) -""" -from subprocess import Popen, PIPE -from os.path import abspath, dirname - - -VERSION = (0, 0, 2, 'final', 0) - - - -def git_sha(): - loc = abspath(dirname(__file__)) - try: - p = Popen( - "cd \"%s\" && git log -1 --format=format:%%h" % loc, - shell=True, - stdout=PIPE, - stderr=PIPE - ) - return p.communicate()[0] - # OSError occurs on Unix-derived platforms lacking Popen's configured shell - # default, /bin/sh. E.g. Android. - except OSError: - return None - - -def get_version(form='short'): - """ - Return a version string for this package, based on `VERSION`. - Takes a single argument, ``form``, which should be one of the following - strings: - * ``branch``: just the major + minor, e.g. "0.9", "1.0". - * ``short`` (default): compact, e.g. "0.9rc1", "0.9.0". For package - filenames or SCM tag identifiers. - * ``normal``: human readable, e.g. "0.9", "0.9.1", "0.9 beta 1". For e.g. - documentation site headers. - * ``verbose``: like ``normal`` but fully explicit, e.g. "0.9 final". For - tag commit messages, or anywhere that it's important to remove ambiguity - between a branch and the first final release within that branch. - * ``all``: Returns all of the above, as a dict. - """ - # Setup - versions = {} - branch = "%s.%s" % (VERSION[0], VERSION[1]) - tertiary = VERSION[2] - type_ = VERSION[3] - final = (type_ == "final") - type_num = VERSION[4] - firsts = "".join([x[0] for x in type_.split()]) - sha = git_sha() - sha1 = (" (%s)" % sha) if sha else "" - - # Branch - versions['branch'] = branch - - # Short - v = branch - if (tertiary or final): - v += "." + str(tertiary) - if not final: - v += firsts - if type_num: - v += str(type_num) - else: - v += sha1 - versions['short'] = v - - # Normal - v = branch - if tertiary: - v += "." + str(tertiary) - if not final: - if type_num: - v += " " + type_ + " " + str(type_num) - else: - v += " pre-" + type_ + sha1 - versions['normal'] = v - - # Verbose - v = branch - if tertiary: - v += "." + str(tertiary) - if not final: - if type_num: - v += " " + type_ + " " + str(type_num) - else: - v += " pre-" + type_ + sha1 - else: - v += " final" - versions['verbose'] = v - - try: - return versions[form] - except KeyError: - if form == 'all': - return versions - raise TypeError('"%s" is not a valid form specifier.' % form) - -__version__ = get_version('short') - -if __name__ == "__main__": - print(get_version('all')) \ No newline at end of file diff --git a/setup.py b/setup.py index c5d7c47..f1a3a65 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,15 @@ -from plugin_info import SHORT_PLUGIN_NAME, packages_required, package_url, author_email, author, description -PLUGIN_NAME = f'pymodaq_plugins_{SHORT_PLUGIN_NAME}' +from setuptools import setup, find_packages +import toml +config = toml.load('./plugin_info.toml') +PLUGIN_NAME = f"pymodaq_plugins_{config['plugin-info']['SHORT_PLUGIN_NAME']}" -import importlib -import sys -try: - import setuptools - from setuptools import setup, find_packages - from setuptools.command import install -except ImportError: - sys.stderr.write("Warning: could not import setuptools; falling back to distutils.\n") - from distutils.core import setup - from distutils.command import install -version = importlib.import_module('.version', PLUGIN_NAME) +from pathlib import Path + +with open(str(Path(__file__).parent.joinpath(f'src/{PLUGIN_NAME}/VERSION')), 'r') as fvers: + version = fvers.read().strip() + with open('README.rst') as fd: long_description = fd.read() @@ -41,14 +37,12 @@ setup( - version=version.get_version(), - packages=find_packages(), + version=version, + packages=find_packages(where='./src'), package_data={'': ['*.dll']}, include_package_data=True, entry_points={'pymodaq.plugins': f'{SHORT_PLUGIN_NAME} = {PLUGIN_NAME}'}, - install_requires=[ - 'pymodaq>=2.0', - ]+packages_required, + install_requires=['toml', ]+config['plugin-install']['packages-required'], **setupOpts ) diff --git a/src/pymodaq_plugins_daqmx/VERSION b/src/pymodaq_plugins_daqmx/VERSION new file mode 100644 index 0000000..6812f81 --- /dev/null +++ b/src/pymodaq_plugins_daqmx/VERSION @@ -0,0 +1 @@ +0.0.3 \ No newline at end of file diff --git a/pymodaq_plugins_daqmx/__init__.py b/src/pymodaq_plugins_daqmx/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/__init__.py rename to src/pymodaq_plugins_daqmx/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_move_plugins/__init__.py b/src/pymodaq_plugins_daqmx/daq_move_plugins/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_move_plugins/__init__.py rename to src/pymodaq_plugins_daqmx/daq_move_plugins/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_move_plugins/daq_move_DAQmx.py b/src/pymodaq_plugins_daqmx/daq_move_plugins/daq_move_DAQmx.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_move_plugins/daq_move_DAQmx.py rename to src/pymodaq_plugins_daqmx/daq_move_plugins/daq_move_DAQmx.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/__init__.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/__init__.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/__init__.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/__init__.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/daq_0Dviewer_DAQmx.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/daq_0Dviewer_DAQmx.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/daq_0Dviewer_DAQmx.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_0D/daq_0Dviewer_DAQmx.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/__init__.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/__init__.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/daq_1Dviewer_DAQmx.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/daq_1Dviewer_DAQmx.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/daq_1Dviewer_DAQmx.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_1D/daq_1Dviewer_DAQmx.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_2D/__init__.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_2D/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_2D/__init__.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_2D/__init__.py diff --git a/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_ND/__init__.py b/src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_ND/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_ND/__init__.py rename to src/pymodaq_plugins_daqmx/daq_viewer_plugins/plugins_ND/__init__.py diff --git a/pymodaq_plugins_daqmx/hardware/__init__.py b/src/pymodaq_plugins_daqmx/hardware/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/hardware/__init__.py rename to src/pymodaq_plugins_daqmx/hardware/__init__.py diff --git a/pymodaq_plugins_daqmx/hardware/national_instruments/__init__.py b/src/pymodaq_plugins_daqmx/hardware/national_instruments/__init__.py similarity index 100% rename from pymodaq_plugins_daqmx/hardware/national_instruments/__init__.py rename to src/pymodaq_plugins_daqmx/hardware/national_instruments/__init__.py diff --git a/pymodaq_plugins_daqmx/hardware/national_instruments/daq_NIDAQmx.py b/src/pymodaq_plugins_daqmx/hardware/national_instruments/daq_NIDAQmx.py similarity index 100% rename from pymodaq_plugins_daqmx/hardware/national_instruments/daq_NIDAQmx.py rename to src/pymodaq_plugins_daqmx/hardware/national_instruments/daq_NIDAQmx.py diff --git a/pymodaq_plugins_daqmx/hardware/national_instruments/daqmx.py b/src/pymodaq_plugins_daqmx/hardware/national_instruments/daqmx.py similarity index 100% rename from pymodaq_plugins_daqmx/hardware/national_instruments/daqmx.py rename to src/pymodaq_plugins_daqmx/hardware/national_instruments/daqmx.py