From 06682cd92ffa55d5f37bc4078f3c67f591803d8b Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Sat, 3 Aug 2024 18:18:48 +0200 Subject: [PATCH 1/5] Add pyproject.toml --- pyproject.toml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7c15ad9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,39 @@ +[build-system] +requires = ["setuptools>=62.3"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.package-data] +aiohuesyncbox = ["py.typed"] + +[tool.setuptools.packages.find] +include = ["aiohuesyncbox*"] + + +[project] +name = "aiohuesyncbox" +version = "0.0.28" +description = "Asyncio package to communicate with a Philips Hue Play HDMI Sync Box." +readme = "README.md" +requires-python = ">=3.8" +authors = [ + {name = "Michel van de Wetering", email = "michel.van.de.wetering@gmail.com" }, +] +license = { text = "Apache-2.0" } +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Topic :: Home Automation", + "Topic :: Software Development :: Libraries", +] +dependencies = ["aiohttp>=3.9.0,<4"] + +urls = { Homepage = "https://github.com/mvdwetering/aiohuesyncbox" } + +[project.optional-dependencies] +test = [ + "mypy==1.11.0", + "ruff==0.5.5", +] \ No newline at end of file From a3855725721852f38596bdc17fdfb608f47a15d8 Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Sat, 3 Aug 2024 18:19:09 +0200 Subject: [PATCH 2/5] Remove old files --- MANIFEST.in | 9 ----- requirements.txt | 1 - setup.cfg | 5 --- setup.py | 96 ------------------------------------------------ 4 files changed, 111 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index e996c7d..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,9 +0,0 @@ -# Include the license file -include LICENSE.txt - -# Include the data files -#recursive-include data * - -# If using Python 2.6 or less, then have to include package data, even though -# it's already declared in setup.py -# include sample/*.dat diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 173359c..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -aiohttp>=3.9.0,<4 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index f645233..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[bdist_wheel] -# This flag says that the code is written to work on both Python 2 and Python -# 3. If at all possible, it is good practice to do this. If you cannot, you -# will need to generate wheels for each Python version that you support. -#universal=1 diff --git a/setup.py b/setup.py deleted file mode 100644 index 3af3802..0000000 --- a/setup.py +++ /dev/null @@ -1,96 +0,0 @@ -"""A setuptools based setup module. - -See: -https://packaging.python.org/en/latest/distributing.html -https://github.com/pypa/sampleproject -""" - -# Always prefer setuptools over distutils -from setuptools import setup, find_packages - -# To use a consistent encoding -from codecs import open -from os import path - -here = path.abspath(path.dirname(__file__)) - -# Get the long description from the README file -with open(path.join(here, "README.md"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="aiohuesyncbox", - # Versions should comply with PEP440. For a discussion on single-sourcing - # the version across setup.py and the project code, see - # https://packaging.python.org/en/latest/single_source_version.html - version="0.0.28", - description="Asyncio package to communicate with a Philips Hue Play HDMI Sync Box.", - long_description=long_description, - long_description_content_type="text/markdown", - # The project's main homepage. - url="https://github.com/mvdwetering/aiohuesyncbox", - # Author details - author="Michel van de Wetering", - author_email="michel.van.de.wetering@gmail.com", - # Choose your license - license="Apache License 2.0", - # See https://pypi.python.org/pypi?%3Aaction=list_classifiers - classifiers=[ - # How mature is this project? Common values are - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - "Development Status :: 5 - Production/Stable", - # Indicate who your project is intended for - "Intended Audience :: Developers", - # Pick your license as you wish (should match "license" above) - "License :: OSI Approved :: Apache Software License", - # Specify the Python versions you support here. In particular, ensure - # that you indicate whether you support Python 2, Python 3 or both. - "Programming Language :: Python :: 3 :: Only", - # Other - "Operating System :: OS Independent", - "Topic :: Home Automation", - "Topic :: Software Development :: Libraries", - ], - # What does your project relate to? - keywords="automation", - # You can just specify the packages manually here if your project is - # simple. Or you can use find_packages(). - packages=find_packages(exclude=["contrib", "docs", "tests"]), - # Alternatively, if you want to distribute just a my_module.py, uncomment - # this: - # py_modules=["my_module"], - # List run-time dependencies here. These will be installed by pip when - # your project is installed. For an analysis of "install_requires" vs pip's - # requirements files see: - # https://packaging.python.org/en/latest/requirements.html - install_requires=list(val.strip() for val in open("requirements.txt")), - # List additional groups of dependencies here (e.g. development - # dependencies). You can install these using the following syntax, - # for example: - # $ pip install -e .[dev,test] - # extras_require={ - # 'dev': ['check-manifest'], - # 'test': ['coverage'], - # }, - # If there are data files included in your packages that need to be - # installed, specify them here. If using Python 2.6 or less, then these - # have to be included in MANIFEST.in as well. - package_data={ - "aiohuesyncbox": ["py.typed"], - }, - # Although 'package_data' is the preferred approach, in some case you may - # need to place data files outside of your packages. See: - # http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files # noqa - # In this case, 'data_file' will be installed into '/my_data' - # data_files=[('my_data', ['data/data_file'])], - # To provide executable scripts, use entry points in preference to the - # "scripts" keyword. Entry points provide cross-platform support and allow - # pip to create the appropriate form of executable for the target platform. - # entry_points={ - # 'console_scripts': [ - # 'aiohuesyncbox=aiohuesyncbox:main', - # ], - # }, -) From de93eaa5b43549dac941c320f9880ca20c5e5be5 Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Sat, 3 Aug 2024 18:19:28 +0200 Subject: [PATCH 3/5] Update github action --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 662e773..40eaf41 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -26,8 +26,8 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install flake8 + pip install . .[test] - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 8b83e4528274dd3933290b631edd01f454924090 Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Sat, 3 Aug 2024 18:19:51 +0200 Subject: [PATCH 4/5] Fix issues found by myp and ruff --- aiohuesyncbox/device.py | 4 ++-- aiohuesyncbox/hdmi.py | 2 +- aiohuesyncbox/hue.py | 4 ++-- aiohuesyncbox/huesyncbox.py | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/aiohuesyncbox/device.py b/aiohuesyncbox/device.py index 4489d61..7a9ae36 100644 --- a/aiohuesyncbox/device.py +++ b/aiohuesyncbox/device.py @@ -26,7 +26,7 @@ class Device: def __init__(self, raw, request) -> None: self._raw = raw self._request = request - self._wifi = Wifi(self._raw["wifi"]) + self._wifi:Wifi|None = Wifi(self._raw["wifi"]) def __str__(self) -> str: attributes = [ @@ -88,7 +88,7 @@ def led_mode(self) -> int: return self._raw["ledMode"] async def set_led_mode(self, mode: int) -> None: - await self._request("put", f"/device", data={"ledMode": mode}) + await self._request("put", "/device", data={"ledMode": mode}) async def update(self) -> None: response = await self._request("get", "/device") diff --git a/aiohuesyncbox/hdmi.py b/aiohuesyncbox/hdmi.py index bbd4dc2..a6a3aaa 100644 --- a/aiohuesyncbox/hdmi.py +++ b/aiohuesyncbox/hdmi.py @@ -1,4 +1,4 @@ -from typing import Dict, List +from typing import Dict from .helpers import generate_attribute_string INPUTS = ["input1", "input2", "input3", "input4"] diff --git a/aiohuesyncbox/hue.py b/aiohuesyncbox/hue.py index 380e2c5..59adf5f 100644 --- a/aiohuesyncbox/hue.py +++ b/aiohuesyncbox/hue.py @@ -1,4 +1,4 @@ -from typing import Dict, List, Optional +from typing import Dict, List from .helpers import generate_attribute_string @@ -109,7 +109,7 @@ async def set_bridge( """Change bridge used by huesyncbox.""" await self._request( "put", - f"/hue", + "/hue", data={ "bridgeUniqueId": bridge_unique_id, "username": username, diff --git a/aiohuesyncbox/huesyncbox.py b/aiohuesyncbox/huesyncbox.py index 454fb38..4e5b693 100644 --- a/aiohuesyncbox/huesyncbox.py +++ b/aiohuesyncbox/huesyncbox.py @@ -1,8 +1,6 @@ import asyncio -import ipaddress import logging import ssl -import socket from typing import Dict, Optional import aiohttp From 980635c4287747d1c6b28e555ac921d1f81d9552 Mon Sep 17 00:00:00 2001 From: Michel van de Wetering Date: Sat, 3 Aug 2024 18:27:15 +0200 Subject: [PATCH 5/5] Update publish github action --- .github/workflows/python-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 671f43a..fbda8e3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -21,11 +21,11 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build - name: Build and publish env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/*