diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 949df6aab..3f143234b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,7 +84,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements-lint.txt + pip install -e .[lint] - name: mypy 3.7 run: | mypy --python-version 3.7 . @@ -125,7 +125,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements-lint.txt + pip install -e .[lint] - name: Code Format Check with Black run: | black --check --verbose . diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml index 68c6f56d8..30f95c103 100644 --- a/.github/workflows/format-code.yml +++ b/.github/workflows/format-code.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements-lint.txt + pip install -e .[lint] - name: Code Format Check with Black run: | black --verbose . diff --git a/can/interfaces/ixxat/canlib.py b/can/interfaces/ixxat/canlib.py index d47fc2d6a..8c07508e4 100644 --- a/can/interfaces/ixxat/canlib.py +++ b/can/interfaces/ixxat/canlib.py @@ -39,7 +39,7 @@ def __init__( tseg1_dbr: int = None, tseg2_dbr: int = None, ssp_dbr: int = None, - **kwargs + **kwargs, ): """ :param channel: @@ -116,7 +116,7 @@ def __init__( tseg1_dbr=tseg1_dbr, tseg2_dbr=tseg2_dbr, ssp_dbr=ssp_dbr, - **kwargs + **kwargs, ) else: if rx_fifo_size is None: @@ -132,7 +132,7 @@ def __init__( rx_fifo_size=rx_fifo_size, tx_fifo_size=tx_fifo_size, bitrate=bitrate, - **kwargs + **kwargs, ) super().__init__(channel=channel, **kwargs) diff --git a/can/interfaces/seeedstudio/seeedstudio.py b/can/interfaces/seeedstudio/seeedstudio.py index 0540c78be..8e0dca8c7 100644 --- a/can/interfaces/seeedstudio/seeedstudio.py +++ b/can/interfaces/seeedstudio/seeedstudio.py @@ -64,7 +64,7 @@ def __init__( operation_mode="normal", bitrate=500000, *args, - **kwargs + **kwargs, ): """ :param str channel: diff --git a/can/io/printer.py b/can/io/printer.py index d0df71db8..40b42862d 100644 --- a/can/io/printer.py +++ b/can/io/printer.py @@ -28,7 +28,7 @@ def __init__( self, file: Optional[Union[StringPathLike, TextIO]] = None, append: bool = False, - **kwargs: Any + **kwargs: Any, ) -> None: """ :param file: An optional path-like object or a file-like object to "print" diff --git a/pyproject.toml b/pyproject.toml index af952e51e..65b8f8aed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,19 +1,142 @@ [build-system] -requires = [ - "setuptools >= 40.8", - "wheel", -] +requires = ["setuptools >= 67.7.2"] build-backend = "setuptools.build_meta" +[project] +name = "python-can" +dynamic = ["readme", "version"] +description = "Controller Area Network interface module for Python" +authors = [{ name = "python-can contributors" }] +dependencies = [ + "wrapt~=1.10", + "packaging >= 23.1", + "setuptools >= 67.7.2", + "typing_extensions>=3.10.0.0", + "msgpack~=1.0.0; platform_system != 'Windows'", + "pywin32>=305; platform_system == 'Windows' and platform_python_implementation == 'CPython'", +] +requires-python = ">=3.7" +license = { text = "LGPL v3" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Education", + "Intended Audience :: Information Technology", + "Intended Audience :: Manufacturing", + "Intended Audience :: Telecommunications Industry", + "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", + "Natural Language :: English", + "Natural Language :: English", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "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", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: System :: Hardware :: Hardware Drivers", + "Topic :: System :: Logging", + "Topic :: System :: Monitoring", + "Topic :: System :: Networking", + "Topic :: Utilities", +] + +[project.scripts] +"can_logconvert.py" = "scripts.can_logconvert:main" +"can_logger.py" = "scripts.can_logger:main" +"can_player.py" = "scripts.can_player:main" +"can_viewer.py" = "scripts.can_viewer:main" + +[project.urls] +homepage = "https://github.com/hardbyte/python-can" +documentation = "https://python-can.readthedocs.io" +repository = "https://github.com/hardbyte/python-can" +changelog = "https://github.com/hardbyte/python-can/blob/develop/CHANGELOG.md" + +[project.optional-dependencies] +lint = [ + "pylint==2.16.4", + "ruff==0.0.260", + "black~=23.1.0", + "mypy==1.0.1", + "mypy-extensions==0.4.3", + "types-setuptools" +] +seeedstudio = ["pyserial>=3.0"] +serial = ["pyserial~=3.0"] +neovi = ["filelock", "python-ics>=2.12"] +canalystii = ["canalystii>=0.1.0"] +cantact = ["cantact>=0.0.7"] +cvector = ["python-can-cvector"] +gs_usb = ["gs_usb>=0.2.1"] +nixnet = ["nixnet>=0.3.2"] +pcan = ["uptime~=3.0.1"] +remote = ["python-can-remote"] +sontheim = ["python-can-sontheim>=0.1.2"] +canine = ["python-can-canine>=0.2.2"] +viewer = [ + "windows-curses; platform_system == 'Windows' and platform_python_implementation=='CPython'" +] +mf4 = ["asammdf>=6.0.0"] + +[tool.setuptools.dynamic] +readme = { file = "README.rst" } +version = { attr = "can.__version__" } + +[tool.setuptools.package-data] +"*" = ["README.rst", "CONTRIBUTORS.txt", "LICENSE.txt", "CHANGELOG.md"] +doc = ["*.*"] +examples = ["*.py"] +can = ["py.typed"] + +[tool.setuptools.packages.find] +include = ["can*", "scripts"] + +[tool.mypy] +warn_return_any = true +warn_unused_configs = true +ignore_missing_imports = true +no_implicit_optional = true +disallow_incomplete_defs = true +warn_redundant_casts = true +warn_unused_ignores = false +exclude = [ + "venv", + "^doc/conf.py$", + "^build", + "^test", + "^setup.py$", + "^can/interfaces/__init__.py", + "^can/interfaces/etas", + "^can/interfaces/gs_usb", + "^can/interfaces/ics_neovi", + "^can/interfaces/iscan", + "^can/interfaces/ixxat", + "^can/interfaces/kvaser", + "^can/interfaces/nican", + "^can/interfaces/neousys", + "^can/interfaces/pcan", + "^can/interfaces/serial", + "^can/interfaces/slcan", + "^can/interfaces/socketcan", + "^can/interfaces/systec", + "^can/interfaces/udp_multicast", + "^can/interfaces/usb2can", + "^can/interfaces/virtual", +] + [tool.ruff] select = [ - "F401", # unused-imports - "UP", # pyupgrade - "I", # isort -] + "F401", # unused-imports + "UP", # pyupgrade + "I", # isort -# Assume Python 3.7. -target-version = "py37" +] [tool.ruff.isort] known-first-party = ["can"] diff --git a/requirements-lint.txt b/requirements-lint.txt deleted file mode 100644 index 829fe5663..000000000 --- a/requirements-lint.txt +++ /dev/null @@ -1,6 +0,0 @@ -pylint==2.16.4 -ruff==0.0.260 -black~=23.1.0 -mypy==1.0.1 -mypy-extensions==0.4.3 -types-setuptools diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3e121b650..000000000 --- a/setup.cfg +++ /dev/null @@ -1,35 +0,0 @@ -[metadata] -license_files = LICENSE.txt - -[mypy] -warn_return_any = True -warn_unused_configs = True -ignore_missing_imports = True -no_implicit_optional = True -disallow_incomplete_defs = True -warn_redundant_casts = True -warn_unused_ignores = False -exclude = - (?x)( - venv - |^doc/conf.py$ - |^test - |^setup.py$ - |^can/interfaces/__init__.py - |^can/interfaces/etas - |^can/interfaces/gs_usb - |^can/interfaces/ics_neovi - |^can/interfaces/iscan - |^can/interfaces/ixxat - |^can/interfaces/kvaser - |^can/interfaces/nican - |^can/interfaces/neousys - |^can/interfaces/pcan - |^can/interfaces/serial - |^can/interfaces/slcan - |^can/interfaces/socketcan - |^can/interfaces/systec - |^can/interfaces/udp_multicast - |^can/interfaces/usb2can - |^can/interfaces/virtual - ) diff --git a/setup.py b/setup.py deleted file mode 100644 index 65298b072..000000000 --- a/setup.py +++ /dev/null @@ -1,104 +0,0 @@ -#!/usr/bin/env python - -""" -Setup script for the `can` package. -Learn more at https://github.com/hardbyte/python-can/ -""" - -import logging -import re -from os import listdir -from os.path import isfile, join - -from setuptools import find_packages, setup - -logging.basicConfig(level=logging.WARNING) - -with open("can/__init__.py", encoding="utf-8") as fd: - version = re.search( - r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE - ).group(1) - -with open("README.rst", encoding="utf-8") as f: - long_description = f.read() - -# Dependencies -extras_require = { - "seeedstudio": ["pyserial>=3.0"], - "serial": ["pyserial~=3.0"], - "neovi": ["filelock", "python-ics>=2.12"], - "canalystii": ["canalystii>=0.1.0"], - "cantact": ["cantact>=0.0.7"], - "cvector": ["python-can-cvector"], - "gs_usb": ["gs_usb>=0.2.1"], - "nixnet": ["nixnet>=0.3.2"], - "pcan": ["uptime~=3.0.1"], - "remote": ["python-can-remote"], - "sontheim": ["python-can-sontheim>=0.1.2"], - "canine": ["python-can-canine>=0.2.2"], - "viewer": [ - 'windows-curses;platform_system=="Windows" and platform_python_implementation=="CPython"' - ], - "mf4": ["asammdf>=6.0.0"], -} - -setup( - # Description - name="python-can", - url="https://github.com/hardbyte/python-can", - description="Controller Area Network interface module for Python", - long_description=long_description, - long_description_content_type="text/x-rst", - classifiers=[ - # a list of all available ones: https://pypi.org/classifiers/ - "Programming Language :: Python", - "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", - "Natural Language :: English", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", - "Operating System :: MacOS", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows", - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Information Technology", - "Intended Audience :: Manufacturing", - "Intended Audience :: Telecommunications Industry", - "Natural Language :: English", - "Topic :: System :: Logging", - "Topic :: System :: Monitoring", - "Topic :: System :: Networking", - "Topic :: System :: Hardware :: Hardware Drivers", - "Topic :: Utilities", - ], - version=version, - packages=find_packages(exclude=["test*", "doc", "scripts", "examples"]), - scripts=list(filter(isfile, (join("scripts/", f) for f in listdir("scripts/")))), - author="python-can contributors", - license="LGPL v3", - package_data={ - "": ["README.rst", "CONTRIBUTORS.txt", "LICENSE.txt", "CHANGELOG.md"], - "doc": ["*.*"], - "examples": ["*.py"], - "can": ["py.typed"], - }, - # Installation - # see https://www.python.org/dev/peps/pep-0345/#version-specifiers - python_requires=">=3.7", - install_requires=[ - "setuptools", - "wrapt~=1.10", - "typing_extensions>=3.10.0.0", - 'pywin32>=305;platform_system=="Windows" and platform_python_implementation=="CPython"', - 'msgpack~=1.0.0;platform_system!="Windows"', - "packaging", - ], - extras_require=extras_require, -)