diff --git a/README.rst b/README.rst index ed04b60..2e7674a 100644 --- a/README.rst +++ b/README.rst @@ -14,13 +14,14 @@ 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 + pip install s2-python[ws] # for S2 over WebSockets -The packages on Pypi may be found `here `_ +The packages on PyPI may be found `here `_ Mypy support ------------ diff --git a/pyproject.toml b/pyproject.toml index 7fd26b9..85788e6 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.13" +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 f675f05..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,53 +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 - [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 diff --git a/src/s2python/s2_connection.py b/src/s2python/s2_connection.py index ba497d4..efbd366 100644 --- a/src/s2python/s2_connection.py +++ b/src/s2python/s2_connection.py @@ -1,3 +1,10 @@ +try: + import websockets +except ImportError as exc: + raise ImportError( + "The 'websockets' package is required. Run 'pip install s2-python[ws]' to use this feature." + ) from exc + import asyncio import json import logging @@ -8,7 +15,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, 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}