diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 82ad4ab..18d3a42 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -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/* diff --git a/pyproject.toml b/pyproject.toml index c401ede..4887874 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 @@ -16,6 +54,7 @@ ignore_missing_imports = true implicit_reexport = true warn_unreachable = true + [tool.pylint.master] ignore = "test" persistent = "no" @@ -78,4 +117,3 @@ output-format = "colorized" [tool.pytest.ini_options] testpaths = "test" -asyncio_mode = "auto" diff --git a/setup.cfg b/setup.cfg index 146effb..2e06d4b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,3 @@ -[metadata] -description-file = README.md - [flake8] exclude = .venv,.git,.tox,bin,lib,deps,build # black requires this diff --git a/setup.py b/setup.py deleted file mode 100644 index d2b6aef..0000000 --- a/setup.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Setup for ets python package.""" -from os import path - -from setuptools import find_packages, setup - -THIS_DIRECTORY = path.abspath(path.dirname(__file__)) -with open(path.join(THIS_DIRECTORY, "README.md"), encoding="utf-8") as f: - LONG_DESCRIPTION = f.read() - -VERSION = {} -# pylint: disable=exec-used -with open( - path.join(THIS_DIRECTORY, "xknxproject/__version__.py"), encoding="utf-8" -) as fp: - exec(fp.read(), VERSION) - -REQUIRES = ["cryptography>=35.0.0", "pyzipper>=0.3.5"] - -setup( - name="xknxproject", - description="A library to gather information from ETS project files used for KNX", - version=VERSION["__version__"], - long_description=LONG_DESCRIPTION, - long_description_content_type="text/markdown", - download_url=f"https://github.com/XKNX/xknxproject/archive/{VERSION['__version__']}.zip", - author="Marvin Wichmann", - author_email="me@marvin-wichmann.de", - license="GNU GPL", - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], - packages=find_packages(include=["xknxproject", "xknxproject.*"]), - package_data={"xknxproject": ["py.typed"]}, - include_package_data=True, - install_requires=REQUIRES, - keywords="knx eib ets ets5 ets6", - zip_safe=False, -) diff --git a/test/conftest.py b/test/conftest.py index 9f9819e..9df8279 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -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" diff --git a/tox.ini b/tox.ini index 9cbb3f5..d96b80a 100644 --- a/tox.ini +++ b/tox.ini @@ -7,7 +7,6 @@ setenv = PYTHONPATH = {toxinidir} commands = pytest --cov xknxproject --cov-report= {posargs} -whitelist_externals = make deps = -rrequirements_testing.txt [testenv:lint] diff --git a/xknxproject/__init__.py b/xknxproject/__init__.py index 61c5070..6cdf56e 100644 --- a/xknxproject/__init__.py +++ b/xknxproject/__init__.py @@ -1,7 +1,3 @@ """ETS Project Parser is a library to parse ETS project files.""" # flake8: noqa from .xknxproj import XKNXProj - -__all__ = [ - "XKNXProj", -] diff --git a/xknxproject/__version__.py b/xknxproject/__version__.py index d4550c3..f738712 100644 --- a/xknxproject/__version__.py +++ b/xknxproject/__version__.py @@ -1,3 +1,3 @@ """ETS Project parser version.""" -__version__ = "2.1.0" +__version__ = "3.0.0" diff --git a/xknxproject/xknxproj.py b/xknxproject/xknxproj.py index c5942f9..eb37d7d 100644 --- a/xknxproject/xknxproj.py +++ b/xknxproject/xknxproj.py @@ -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", ) diff --git a/xknxproject/zip/extractor.py b/xknxproject/zip/extractor.py index bea3b6b..2cd5ea5 100644 --- a/xknxproject/zip/extractor.py +++ b/xknxproject/zip/extractor.py @@ -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)