From d9f56c6454aef04632875fc9f8d155e8dc083886 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 09:34:35 +0200 Subject: [PATCH 1/8] chore: websockets dependency is optional Signed-off-by: F.N. Claessen --- setup.cfg | 4 ++++ src/s2python/s2_connection.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f675f05..0bf12e5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -44,6 +44,10 @@ install_requires = click websockets~=13.1 +[project.optional-dependencies] +ws = + websockets + [options.packages.find] where = src exclude = diff --git a/src/s2python/s2_connection.py b/src/s2python/s2_connection.py index ba497d4..b490a35 100644 --- a/src/s2python/s2_connection.py +++ b/src/s2python/s2_connection.py @@ -1,3 +1,8 @@ +try: + import websockets +except ImportError: + raise ImportError("You need to run 'pip install s2-python[ws]' to use this feature.") + import asyncio import json import logging @@ -8,7 +13,6 @@ from dataclasses import dataclass from typing import Any, Optional, List, Type, Dict, Callable, Awaitable, Union -import websockets from websockets.asyncio.client import ( ClientConnection as WSConnection, connect as ws_connect, From 480d2f915a2ab655186024e0c53b12e276a958fe Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 10:13:42 +0200 Subject: [PATCH 2/8] docs: fix capitalization Signed-off-by: F.N. Claessen --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ed04b60..474f277 100644 --- a/README.rst +++ b/README.rst @@ -14,13 +14,13 @@ Currently, the package supports the *common* and *FILL RATE BASED CONTROL* types To Install ----------- -You can install this package using pip or any Python dependency manager that collects the packages from Pypi: +You can install this package using pip or any Python dependency manager that collects the packages from PyPI: .. code-block:: bash pip install s2-python -The packages on Pypi may be found `here `_ +The packages on PyPI may be found `here `_ Mypy support ------------ From ba580adad4d2c68e23365f4653ea5bdab6e843aa Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 10:15:36 +0200 Subject: [PATCH 3/8] docs: add installation instruction Signed-off-by: F.N. Claessen --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 474f277..2e7674a 100644 --- a/README.rst +++ b/README.rst @@ -19,6 +19,7 @@ You can install this package using pip or any Python dependency manager that col .. code-block:: bash pip install s2-python + pip install s2-python[ws] # for S2 over WebSockets The packages on PyPI may be found `here `_ From 35a0ffd1cb43441e09feb2cc015bb076685d97b5 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 10:20:41 +0200 Subject: [PATCH 4/8] fix: add ws to tox testenv Signed-off-by: F.N. Claessen --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index deeca3b..fbef9e5 100644 --- a/tox.ini +++ b/tox.ini @@ -14,6 +14,7 @@ passenv = SETUPTOOLS_* extras = testing + ws commands = pytest {posargs} From 284665f74d6295bea179a68eb997be3d40fc8153 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 10:24:40 +0200 Subject: [PATCH 5/8] style: pylint Signed-off-by: F.N. Claessen --- src/s2python/s2_connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/s2python/s2_connection.py b/src/s2python/s2_connection.py index b490a35..c63d180 100644 --- a/src/s2python/s2_connection.py +++ b/src/s2python/s2_connection.py @@ -1,7 +1,7 @@ try: import websockets -except ImportError: - raise ImportError("You need to run 'pip install s2-python[ws]' to use this feature.") +except ImportError as exc: + raise ImportError("You need to run 'pip install s2-python[ws]' to use this feature.") from exc import asyncio import json From c09106089618815d6e30fbd55abe928e1a7a0739 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 13:01:46 +0200 Subject: [PATCH 6/8] fix: move most setup.cfg fields to pyproject.toml; NB `install_requires` becomes `dependencies` and `extras_require` becomes `optional-dependencies` Signed-off-by: F.N. Claessen --- pyproject.toml | 60 +++++++++++++++++++++++++++++++++++++++++++- setup.cfg | 67 -------------------------------------------------- 2 files changed, 59 insertions(+), 68 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 7fd26b9..aecc451 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,61 @@ [build-system] requires = ["setuptools"] -build-backend = "setuptools.build_meta" \ No newline at end of file +build-backend = "setuptools.build_meta" + +[project] +name = "s2-python" +authors = [ + {name = "Flexiblepower", email = "info@info.nl"} +] +description = "S2 Protocol Python Wrapper" +version = "0.5.0" +readme = "README.rst" +license = "Apache-2.0" +license-files = ["LICENSE"] +requires-python = ">=3.8, <= 3.12" +dependencies = [ + "pydantic>=2.8.2", + "pytz", + "click", +] +classifiers = [ + "Development Status :: 4 - Beta", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +[project.urls] + "Source code" = "https://github.com/flexiblepower/s2-ws-json-python" + +[project.optional-dependencies] +ws = [ + "websockets~=13.1", +] +testing = [ + "pytest", + "pytest-coverage", + "pytest-timer", + "mypy", + "types-pytz", + "pylint", + "pyright", +] +development = [ + "pip-tools", + "datamodel-code-generator", + "pre-commit", + "tox", +] +docs = [ + "sphinx", + "sphinx-rtd-theme >= 1.2", + "sphinx-tabs", + "sphinx_copybutton", + "sphinx_fontawesome", + "sphinxcontrib.httpdomain", +] + +[project.scripts] +s2python = "s2python.tools.cli:s2python_cmd" diff --git a/setup.cfg b/setup.cfg index 0bf12e5..c61fc67 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,29 +1,8 @@ [metadata] -name = s2-python -description = S2 Protocol Python Wrapper -author = Flexiblepower -author_email = info@info.nl -license = APACHE -license_files = LICENSE.txt -long_description = file: README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -url = https://github.com/flexiblepower/s2-ws-json-python -version = 0.5.0 # Change if running only on Windows, Mac or Linux (comma-separated) platforms = Linux -# Add here all kinds of additional classifiers as defined under -# https://pypi.org/classifiers/ -classifiers = - Development Status :: 4 - Beta - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3.12 - - [options] zip_safe = False packages = find_namespace: @@ -31,57 +10,11 @@ include_package_data = True package_dir = =src -# Require a min/specific Python version (comma-separated conditions) -python_requires >= 3.8, <= 3.12 - -# Add here dependencies of your project (line-separated), e.g. requests>=2.2,<3.0. -# Version specifiers like >=2.2,<3.0 avoid problems due to API changes in -# new major versions. This works if the required packages follow Semantic Versioning. -# For more information, check out https://semver.org/. -install_requires = - pydantic>=2.8.2 - pytz - click - websockets~=13.1 - -[project.optional-dependencies] -ws = - websockets - [options.packages.find] where = src exclude = tests -[options.extras_require] -testing = - pytest - pytest-coverage - pytest-timer - mypy - types-pytz - pylint - pyright - - -development = - pip-tools - datamodel-code-generator - pre-commit - tox - -docs = - sphinx - sphinx-rtd-theme >= 1.2 - sphinx-tabs - sphinx_copybutton - sphinx_fontawesome - sphinxcontrib.httpdomain - -[options.entry_points] -console_scripts = - s2python = s2python.tools.cli:s2python_cmd - [tool:pytest] addopts = --cov=s2python From 07858aa041d2de90e0636c80e793193604fb08d7 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 13:04:45 +0200 Subject: [PATCH 7/8] fix: review comment Signed-off-by: F.N. Claessen --- src/s2python/s2_connection.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/s2python/s2_connection.py b/src/s2python/s2_connection.py index c63d180..efbd366 100644 --- a/src/s2python/s2_connection.py +++ b/src/s2python/s2_connection.py @@ -1,7 +1,9 @@ try: import websockets except ImportError as exc: - raise ImportError("You need to run 'pip install s2-python[ws]' to use this feature.") from exc + raise ImportError( + "The 'websockets' package is required. Run 'pip install s2-python[ws]' to use this feature." + ) from exc import asyncio import json From c52bc7aa81143a9f28262ee01ff61639cca9aae9 Mon Sep 17 00:00:00 2001 From: "F.N. Claessen" Date: Tue, 15 Apr 2025 14:03:55 +0200 Subject: [PATCH 8/8] fix: relax upper Python pin Signed-off-by: F.N. Claessen --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index aecc451..85788e6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ version = "0.5.0" readme = "README.rst" license = "Apache-2.0" license-files = ["LICENSE"] -requires-python = ">=3.8, <= 3.12" +requires-python = ">=3.8, < 3.13" dependencies = [ "pydantic>=2.8.2", "pytz",