From 272c77fe5059c221c91ae91d4a8f02234265da2e Mon Sep 17 00:00:00 2001 From: Stefan Tatschner Date: Tue, 24 Sep 2024 13:39:49 +0200 Subject: [PATCH] chore: Make httpx dependency optional The usecase for the http powersupply is very rare. Maybe we will remove that entirely in the future once we have ported [this](https://github.com/rumpelsepp/opennetzteil/blob/master/devices/rnd/rnd320.go) to gallia. --- poetry.lock | 15 +++++++++------ pyproject.toml | 5 ++++- src/opennetzteil/__init__.py | 10 ++++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/poetry.lock b/poetry.lock index 18fbaf556..d6aa031fa 100644 --- a/poetry.lock +++ b/poetry.lock @@ -55,7 +55,7 @@ files = [ name = "anyio" version = "4.4.0" description = "High level compatibility layer for multiple asynchronous event loop implementations" -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "anyio-4.4.0-py3-none-any.whl", hash = "sha256:c1b2d8f46a8a812513012e1107cb0e68c17159a7a594208005a57dc776e1bdc7"}, @@ -492,7 +492,7 @@ files = [ name = "h11" version = "0.14.0" description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, @@ -503,7 +503,7 @@ files = [ name = "httpcore" version = "1.0.5" description = "A minimal low-level HTTP client." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "httpcore-1.0.5-py3-none-any.whl", hash = "sha256:421f18bac248b25d310f3cacd198d55b8e6125c107797b609ff9b7a6ba7991b5"}, @@ -524,7 +524,7 @@ trio = ["trio (>=0.22.0,<0.26.0)"] name = "httpx" version = "0.27.2" description = "The next generation HTTP client." -optional = false +optional = true python-versions = ">=3.8" files = [ {file = "httpx-0.27.2-py3-none-any.whl", hash = "sha256:7bb2708e112d8fdd7829cd4243970f0c223274051cb35ee80c03301ee29a3df0"}, @@ -1589,7 +1589,7 @@ files = [ name = "sniffio" version = "1.3.1" description = "Sniff out which async library your code is running under" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "sniffio-1.3.1-py3-none-any.whl", hash = "sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2"}, @@ -2132,7 +2132,10 @@ cffi = {version = ">=1.11", markers = "platform_python_implementation == \"PyPy\ [package.extras] cffi = ["cffi (>=1.11)"] +[extras] +http-powersupply = ["httpx"] + [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.13" -content-hash = "5bfb99555575baa993a00e4d837942eb4e29471c7c076f5ea999a0d95b76feea" +content-hash = "93a8f14bf24ae535736ca79920de2d6700353781172186794a902a23ec307030" diff --git a/pyproject.toml b/pyproject.toml index fab016431..b3b5d5310 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,9 +45,12 @@ msgspec = ">=0.11,<0.19" pydantic = "^2.0" platformdirs = ">=2.6,<5.0" psutil = ">=5.9.4,<7.0.0" -httpx = ">=0.26,<0.28" +httpx = { version = ">=0.26,<0.28", optional = true } more-itertools = "^10.3.0" +[tool.poetry.extras] +http-powersupply = ["httpx"] + [tool.poetry.group.dev.dependencies] Sphinx = ">=5.2,<8.0" mypy = "^1.0" diff --git a/src/opennetzteil/__init__.py b/src/opennetzteil/__init__.py index 7aed4015c..813baeeca 100644 --- a/src/opennetzteil/__init__.py +++ b/src/opennetzteil/__init__.py @@ -2,8 +2,14 @@ # # SPDX-License-Identifier: Apache-2.0 -from opennetzteil.devices.http.client import HTTPNetzteil from opennetzteil.devices.rs.hmc804 import HMC804 from opennetzteil.netzteil import BaseNetzteil -netzteile: list[type[BaseNetzteil]] = [HTTPNetzteil, HMC804] +netzteile: list[type[BaseNetzteil]] = [HMC804] + +try: + from opennetzteil.devices.http.client import HTTPNetzteil + + netzteile.append(HTTPNetzteil) +except ImportError: + pass