8.5.1.4. pymodaq_utils.plugin_tools.platforms module

Operating systems and processor architectures supported by an instrument plugin.

A plugin that only works on some systems (a Windows driver, a Raspberry Pi board…) declares it in the class of its instrument plugin:

class DAQ_Move_Xxxx(DAQ_Move_base):
    supported_platforms = ('win32',)                   # values of sys.platform: 'win32', 'linux', 'darwin'
    supported_architectures = ('aarch64', 'armv7l')    # optional, values of platform.machine()

None (the default of the base classes) means all of them. PyMoDAQ then refuses to initialize the plugin on another system, with a message, and check_plugin reads the declaration to check (and update with --fix-classifiers) the Operating System classifiers of the pyproject.toml.

Added in version 5.3.5.

pymodaq_utils.plugin_tools.platforms.classifiers_for(platforms=None)[source]

The Operating System classifiers of a plugin working on these systems (None: OS independent)

Return type:

list[str]

pymodaq_utils.plugin_tools.platforms.declared_in_class(cls)[source]

(supported_platforms, supported_architectures) written in the body of a plugin class (None if absent or not a literal)

Return type:

tuple[Optional[tuple], Optional[tuple]]

pymodaq_utils.plugin_tools.platforms.describe(platforms=None, architectures=None)[source]

Text for the user, for instance Linux (aarch64, armv7l); empty if there is no restriction

Return type:

str

pymodaq_utils.plugin_tools.platforms.dynamic_classifiers(pyproject, package_folder)[source]

The classifiers of a plugin whose classifiers field is dynamic in the pyproject.toml: those listed in [tool.pymodaq] classifiers (the Operating System and Programming Language :: Python :: 3.x ones are ignored) followed by the Python versions accepted by requires-python and the systems computed from the supported_platforms of its instrument plugins. Used by the hatch metadata hook at build time

Return type:

list[str]

pymodaq_utils.plugin_tools.platforms.invalid_values(platforms, architectures)[source]

Problems of a declaration: unknown system or architecture names, empty lists

Return type:

list[str]

pymodaq_utils.plugin_tools.platforms.normalize_architecture(machine)[source]

Canonical name of an architecture (arm64 -> aarch64…), the lowercased input if unknown

Return type:

str

pymodaq_utils.plugin_tools.platforms.package_platforms(root)[source]

Systems on which the instruments of a plugin package work (union over the instrument modules), read from the sources. None if at least one instrument works on all of them

Return type:

Optional[set]

pymodaq_utils.plugin_tools.platforms.platforms_as_rst()[source]

The accepted values as two reStructuredText tables, to be included in the documentation

Return type:

str

pymodaq_utils.plugin_tools.platforms.pyproject_os_classifiers(classifiers)[source]
Return type:

list[str]

pymodaq_utils.plugin_tools.platforms.python_classifiers(requires_python='')[source]

Programming Language :: Python :: 3.x for each of PYTHON_VERSIONS accepted by requires-python (all of them if empty or invalid)

Return type:

list[str]

pymodaq_utils.plugin_tools.platforms.unsupported_reason(platforms=None, architectures=None, system=None, machine=None)[source]

Why a plugin cannot run on this computer, or an empty string if it can

Parameters:
  • platforms (Optional[Iterable[str]]) – values of sys.platform the plugin works on (None: all). A prefix is enough: linux matches linux2

  • architectures (Optional[Iterable[str]]) – values of platform.machine() the plugin works on (None: all)

  • system (Optional[str]) – replace sys.platform and platform.machine(), for tests

  • machine (Optional[str]) – replace sys.platform and platform.machine(), for tests

Return type:

str

pymodaq_utils.plugin_tools.platforms.update_pyproject_classifiers(pyproject, platforms)[source]

Replace the Operating System classifiers in the classifiers list of a pyproject.toml (a text edit, the rest of the file is kept). Returns True if the file changed

Return type:

bool

pymodaq_utils.plugin_tools.platforms.windows_only_files(root)[source]

Python files of a plugin package that only the Windows-only instruments use (directly or through the other modules): code that only works on Windows is expected there. All of them if every instrument declares supported_platforms = ('win32',). Files used by an instrument working elsewhere are never in it

Return type:

set

pymodaq_utils.plugin_tools.platforms.ARCHITECTURES = {'aarch64': ('aarch64', 'arm64'), 'armv6l': ('armv6l',), 'armv7l': ('armv7l', 'armv8l'), 'i686': ('i686', 'i386', 'x86'), 'x86_64': ('x86_64', 'amd64')}

values of platform.machine() (compared without case), with their aliases

pymodaq_utils.plugin_tools.platforms.PLATFORMS = {'darwin': ('macOS', 'Operating System :: MacOS'), 'linux': ('Linux', 'Operating System :: POSIX :: Linux'), 'win32': ('Windows', 'Operating System :: Microsoft :: Windows')}

values of sys.platform and the matching name and PyPI classifier

pymodaq_utils.plugin_tools.platforms.PYTHON_VERSIONS = ('3.10', '3.11', '3.12', '3.13')

Python versions PyMoDAQ is developed for, they give the Programming Language :: Python classifiers