diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 72a27d04..0e6d2b2f 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -16,10 +16,10 @@ jobs: python-version: 3.8 - name: Install wheel run: >- - pip install wheel + pip install wheel build - name: Build run: >- - python3 setup.py sdist bdist_wheel + python3 -m build - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@master with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 903cc233..bededc22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,6 +21,8 @@ repos: rev: 6.0.0 hooks: - id: flake8 + additional_dependencies: + - Flake8-pyproject==1.2.3 - repo: https://github.com/PyCQA/isort rev: 5.12.0 diff --git a/bellows/__init__.py b/bellows/__init__.py index 80d1a083..e69de29b 100644 --- a/bellows/__init__.py +++ b/bellows/__init__.py @@ -1,5 +0,0 @@ -MAJOR_VERSION = 0 -MINOR_VERSION = 36 -PATCH_VERSION = "0.dev0" -__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}" -__version__ = f"{__short_version__}.{PATCH_VERSION}" diff --git a/bellows/zigbee/application.py b/bellows/zigbee/application.py index 9e58ad61..d6620e78 100644 --- a/bellows/zigbee/application.py +++ b/bellows/zigbee/application.py @@ -11,6 +11,8 @@ else: from asyncio import timeout as asyncio_timeout # pragma: no cover +import importlib.metadata + import zigpy.application import zigpy.config import zigpy.device @@ -264,7 +266,7 @@ async def load_network_info(self, *, load_devices=False) -> None: can_rewrite_custom_eui64 = await ezsp.can_rewrite_custom_eui64() self.state.network_info = zigpy.state.NetworkInfo( - source=f"bellows@{bellows.__version__}", + source=f"bellows@{importlib.metadata.version('bellows')}", extended_pan_id=zigpy.types.ExtendedPanId(nwk_params.extendedPanId), pan_id=zigpy.types.PanId(nwk_params.panId), nwk_update_id=zigpy.types.uint8_t(nwk_params.nwkUpdateId), diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..833b15b6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,66 @@ +[build-system] +requires = ["setuptools>=61.0.0", "wheel", "setuptools-git-versioning<2"] +build-backend = "setuptools.build_meta" + +[project] +name = "bellows" +dynamic = ["version"] +description = "Library implementing EZSP" +urls = {repository = "https://github.com/zigpy/bellows"} +authors = [ + {name = "Russell Cloran", email = "rcloran@gmail.com"} +] +readme = "README.md" +license = {text = "GPL-3.0"} +requires-python = ">=3.8" +dependencies = [ + "click", + "click-log>=0.2.1", + "pure_pcapy3==1.0.1", + "voluptuous", + "zigpy>=0.54.1", + 'async-timeout; python_version<"3.11"', +] + +[tool.setuptools.packages.find] +exclude = ["tests", "tests.*"] + +[project.optional-dependencies] +testing = [ + "pytest>=7.1.2", + "pytest-asyncio>=0.19.0", + "pytest-timeout>=2.1.0", + "pytest-mock>=3.8.2", + "pytest-cov>=3.0.0", +] + +[tool.setuptools-git-versioning] +enabled = true + +[project.scripts] +bellows = "bellows.cli.main:main" + +[tool.isort] +profile = "black" +# will group `import x` and `from x import` of the same module. +force_sort_within_sections = true +known_first_party = ["bellows", "tests"] +forced_separate = "tests" +combine_as_imports = true + +[tool.mypy] +ignore_errors = true + +[tool.pytest.ini_options] +asyncio_mode = "auto" + +[tool.flake8] +exclude = [".venv", ".git", ".tox", "docs", "venv", "bin", "lib", "deps", "build"] +# To work with Black +max-line-length = 88 +# W503: Line break occurred before a binary operator +# E203: Whitespace before ':' +# E501: line too long +# D202 No blank lines allowed after function docstring +ignore = ["W503", "E203", "E501", "D202"] +per-file-ignores = ["tests/*:F811,F401,F403"] \ No newline at end of file diff --git a/requirements_test.txt b/requirements_test.txt index 5fbb4e49..2f3dfb37 100644 --- a/requirements_test.txt +++ b/requirements_test.txt @@ -16,4 +16,5 @@ pytest-timeout pytest-asyncio>=0.17 pytest>=7.1.3 zigpy>=0.54.1 -ruff==0.0.261 \ No newline at end of file +ruff==0.0.261 +Flake8-pyproject \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a19f6c80..00000000 --- a/setup.cfg +++ /dev/null @@ -1,30 +0,0 @@ -[flake8] -exclude = .venv,.git,.tox,docs,venv,bin,lib,deps,build -# To work with Black -max-line-length = 88 -# W503: Line break occurred before a binary operator -# E203: Whitespace before ':' -# E501: line too long -# D202 No blank lines allowed after function docstring -ignore = - W503, - E203, - E501, - D202 - -per-file-ignores = - tests/*:F811,F401,F403 - -[isort] -profile = black -# will group `import x` and `from x import` of the same module. -force_sort_within_sections = true -known_first_party = bellows,tests -forced_separate = tests -combine_as_imports = true - -[tool:pytest] -asyncio_mode = auto - -[mypy] -ignore_errors = True \ No newline at end of file diff --git a/setup.py b/setup.py index 030acf6d..1abbd068 100644 --- a/setup.py +++ b/setup.py @@ -1,29 +1,4 @@ -"""Setup module for bellows""" +import setuptools -from setuptools import find_packages, setup - -import bellows - -setup( - name="bellows", - version=bellows.__version__, - description="Library implementing EZSP", - url="http://github.com/zigpy/bellows", - author="Russell Cloran", - author_email="rcloran@gmail.com", - license="GPL-3.0", - packages=find_packages(exclude=["tests", "tests.*"]), - entry_points={"console_scripts": ["bellows=bellows.cli.main:main"]}, - install_requires=[ - "click", - "click-log>=0.2.1", - "pure_pcapy3==1.0.1", - "voluptuous", - "zigpy>=0.54.1", - 'async-timeout; python_version<"3.11"', - ], - dependency_links=[ - "https://codeload.github.com/rcloran/pure-pcapy-3/zip/master", - ], - tests_require=["asynctest", "pytest", "pytest-asyncio"], -) +if __name__ == "__main__": + setuptools.setup() diff --git a/tests/test_application_network_state.py b/tests/test_application_network_state.py index b3590303..7bb370e4 100644 --- a/tests/test_application_network_state.py +++ b/tests/test_application_network_state.py @@ -1,9 +1,10 @@ +import importlib.metadata + import pytest import zigpy.state import zigpy.types as zigpy_t import zigpy.zdo.types as zdo_t -import bellows from bellows.exception import EzspError import bellows.types as t @@ -70,7 +71,7 @@ def network_info(node_info): zigpy_t.EUI64.convert("00:0b:57:ff:fe:2b:d4:57"): zigpy_t.NWK(0xC06B), }, stack_specific={"ezsp": {"hashed_tclk": "abcdabcdabcdabcdabcdabcdabcdabcd"}}, - source=f"bellows@{bellows.__version__}", + source=f"bellows@{importlib.metadata.version('bellows')}", )