Skip to content

Commit

Permalink
Migrate to pyproject.toml and Git versioning (#568)
Browse files Browse the repository at this point in the history
* Migrate to `pyproject.toml`

* Switch from `setup.py bdist_wheel` to `python -m build`
  • Loading branch information
puddly authored Jun 23, 2023
1 parent a93f8ac commit ce71a2d
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 69 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions bellows/__init__.py
Original file line number Diff line number Diff line change
@@ -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}"
4 changes: 3 additions & 1 deletion bellows/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
66 changes: 66 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]"}
]
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"]
3 changes: 2 additions & 1 deletion requirements_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ pytest-timeout
pytest-asyncio>=0.17
pytest>=7.1.3
zigpy>=0.54.1
ruff==0.0.261
ruff==0.0.261
Flake8-pyproject
30 changes: 0 additions & 30 deletions setup.cfg

This file was deleted.

31 changes: 3 additions & 28 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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="[email protected]",
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()
5 changes: 3 additions & 2 deletions tests/test_application_network_state.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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')}",
)


Expand Down

0 comments on commit ce71a2d

Please sign in to comment.