Skip to content

Commit

Permalink
Use pyproject.toml for specifying project metadata (#212)
Browse files Browse the repository at this point in the history
* Use pyproject.toml for packaging

* add minimum version requirements
  • Loading branch information
farmio authored Apr 25, 2023
1 parent 2ca029c commit c7c7f21
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 59 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python -m pip install build twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
python -m build
twine upload dist/*
40 changes: 39 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@
[build-system]
requires = ["setuptools~=62.3"]
build-backend = "setuptools.build_meta"

[project]
name = "xknxproject"
authors = [
{name = "Marvin Wichmann", email = "me@marvin-wichmann.de"},
{name = "Matthias Alphart", email = "farmio@alphart.net"},
]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3",
]
dependencies = [
"cryptography>=40.0.0",
"pyzipper>=0.3.6",
]
description = "A library to gather information from ETS project files used for KNX"
dynamic = ["version"]
keywords = ["KNX", "ETS", "Home Assistant"]
license = {file = "LICENSE"}
readme = "README.md"
requires-python = ">=3.9.0"

[project.urls]
homepage = "https://github.com/XKNX/xknxproject"


[tool.setuptools.dynamic]
version = {attr = "xknxproject.__version__.__version__"}

[tool.setuptools.packages.find]
include = ["xknxproject*"]

[tool.black]
target-version = ["py39", "py310", "py311"]
exclude = "generated"


[tool.isort]
profile = "black"
# will group `import x` and `from x import` of the same module.
force_sort_within_sections = true
combine_as_imports = true


[tool.mypy]
python_version = "3.9"
strict = true
Expand All @@ -16,6 +54,7 @@ ignore_missing_imports = true
implicit_reexport = true
warn_unreachable = true


[tool.pylint.master]
ignore = "test"
persistent = "no"
Expand Down Expand Up @@ -78,4 +117,3 @@ output-format = "colorized"

[tool.pytest.ini_options]
testpaths = "test"
asyncio_mode = "auto"
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[metadata]
description-file = README.md

[flake8]
exclude = .venv,.git,.tox,bin,lib,deps,build
# black requires this
Expand Down
42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

9 changes: 8 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ def assert_stub(to_be_verified: KNXProject, stub_name: str) -> None:
"""Assert input matched loaded stub file."""
stub_path = STUBS_PATH / stub_name

def remove_xknxproject_version(obj: KNXProject) -> KNXProject:
"""Remove xknxproject_version from object."""
version_string = obj["info"].pop("xknxproject_version")
assert len(version_string.split(".")) == 3
return obj

with open(stub_path, encoding="utf-8") as stub_file:
stub = json.load(stub_file)
stub = remove_xknxproject_version(json.load(stub_file))
to_be_verified = remove_xknxproject_version(to_be_verified)
for key, value in stub.items():
assert key in to_be_verified, f"`{key}` key missing in generated object"
assert value == to_be_verified[key], f"`{key}` item does not match"
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ setenv =
PYTHONPATH = {toxinidir}
commands =
pytest --cov xknxproject --cov-report= {posargs}
whitelist_externals = make
deps = -rrequirements_testing.txt

[testenv:lint]
Expand Down
4 changes: 0 additions & 4 deletions xknxproject/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
"""ETS Project Parser is a library to parse ETS project files."""
# flake8: noqa
from .xknxproj import XKNXProj

__all__ = [
"XKNXProj",
]
2 changes: 1 addition & 1 deletion xknxproject/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""ETS Project parser version."""

__version__ = "2.1.0"
__version__ = "3.0.0"
4 changes: 1 addition & 3 deletions xknxproject/xknxproj.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ def __init__(
self.password = password
self.language = language

self.version = __version__

def parse(self) -> KNXProject:
"""Parse the KNX project."""
_LOGGER.info(
'Xknxproject version %s parsing "%s" with%s password...',
self.version,
__version__,
self.path,
"" if self.password else "out",
)
Expand Down
2 changes: 1 addition & 1 deletion xknxproject/zip/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def extract(
archive_path: Path, password: str | None = None
) -> Iterator[KNXProjContents]:
"""Provide the contents of a KNXProj file."""
_LOGGER.debug("Opening KNX Project file %s", archive_path)
_LOGGER.debug('Opening KNX Project file "%s"', archive_path)
with ZipFile(archive_path, mode="r") as zip_archive:
project_id = _get_project_id(zip_archive)
xml_namespace = _get_xml_namespace(zip_archive)
Expand Down

0 comments on commit c7c7f21

Please sign in to comment.