Skip to content

Remove package versioning from Git repo and migrate to pyproject.toml #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
name: Publish distributions to PyPI and TestPyPI
on:
push:
tags:
- "*"
release:
types:
- published

jobs:
build-and-publish:
name: Build and publish distributions to PyPI and TestPyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v3
- name: Set up Python 3.8
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Set package version
run: |
version="${{ github.event.release.tag_name }}"
version="${version,,}" # lowercase it
version="${version#v}" # remove `v`
sed -i "s/version = \"0\.0\.0\"/version = \"${version}\"/" pyproject.toml
- 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
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_TOKEN }}
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ repos:
- id: mypy
additional_dependencies:
- zigpy
- types-setuptools

- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
Expand Down
61 changes: 34 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,40 @@
[build-system]
requires = ["setuptools>=34.4.0", "wheel"]
requires = ["setuptools>=61.0.0"]
build-backend = "setuptools.build_meta"

[project]
name = "zigpy-znp"
version = "0.0.0"
description = "A library for zigpy which communicates with TI ZNP radios"
urls = {repository = "https://github.com/zigpy/zigpy-znp"}
authors = [
{name = "Alexei Chetroi", email = "[email protected]"}
]
readme = "README.md"
license = {text = "GPL-3.0"}
requires-python = ">=3.8"
dependencies = [
"zigpy>=0.52.0",
"async_timeout",
"voluptuous",
"coloredlogs",
"jsonschema",
]

[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",
"coveralls",
]


[tool.black]
safe = true
quiet = true
Expand Down Expand Up @@ -56,29 +89,3 @@ source = ["zigpy_znp"]

[tool.pyupgrade]
py37plus = true

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py37, py38, py39, lint, black
skip_missing_interpreters = True

[testenv]
setenv = PYTHONPATH = {toxinidir}
extras = testing
commands = py.test --cov --cov-report=html

[testenv:lint]
basepython = python3
deps = flake8
commands = flake8

[testenv:black]
deps =
black==20.8.b1
setenv =
LC_ALL=C.UTF-8
LANG=C.UTF-8
commands=
black --check --fast {toxinidir}/zigpy_znp {toxinidir}/tests {toxinidir}/setup.py
"""
36 changes: 0 additions & 36 deletions setup.cfg

This file was deleted.

6 changes: 0 additions & 6 deletions zigpy_znp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@
MAJOR_VERSION = 0
MINOR_VERSION = 9
PATCH_VERSION = 2

__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
5 changes: 3 additions & 2 deletions zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

import zigpy.state
import async_timeout
import pkg_resources
import zigpy.zdo.types as zdo_t
import zigpy.exceptions
from zigpy.exceptions import NetworkNotFormed

import zigpy_znp
import zigpy_znp.const as const
import zigpy_znp.types as t
import zigpy_znp.config as conf
Expand Down Expand Up @@ -136,9 +136,10 @@ async def _load_network_info(self, *, load_devices=False):
)

version = await self.request(c.SYS.Version.Req())
package_version = pkg_resources.get_distribution("zigpy_znp").version

network_info = zigpy.state.NetworkInfo(
source=f"zigpy-znp@{zigpy_znp.__version__}",
source=f"zigpy-znp@{package_version}",
extended_pan_id=nib.extendedPANID,
pan_id=nib.nwkPanId,
nwk_update_id=nib.nwkUpdateId,
Expand Down
5 changes: 3 additions & 2 deletions zigpy_znp/tools/network_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import datetime

import zigpy.state
import pkg_resources

import zigpy_znp
import zigpy_znp.types as t
from zigpy_znp.api import ZNP
from zigpy_znp.tools.common import ClosableFileType, setup_parser, validate_backup_json
Expand Down Expand Up @@ -84,7 +84,8 @@ async def backup_network(znp: ZNP) -> t.JSONType:

now = datetime.datetime.now().astimezone()

obj["metadata"]["source"] = f"zigpy-znp@{zigpy_znp.__version__}"
package_version = pkg_resources.get_distribution("zigpy_znp").version
obj["metadata"]["source"] = f"zigpy-znp@{package_version}"
obj["metadata"]["internal"] = {
"creation_time": now.isoformat(timespec="seconds"),
"zstack": {
Expand Down