diff --git a/CHANGELOG.md b/CHANGELOG.md index bef723f..0a87f54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,16 @@ - Aligned `search()` parameters with the current documented API surface. - Modernized packaging metadata: updated repository URL, classifiers, and dependency pins. - Unified package version to `0.1.0` across `setup.py` and `currentsapi/__init__.py`. +- Single-sourced the version: `setup.py` now reads `__version__` from + `currentsapi/__init__.py` instead of duplicating it. +- Replaced the deprecated `tests_require` argument with an `extras_require` + `"dev"` extra (`pip install currentsapi[dev]`). +- Removed obsolete `setup.cfg`: the `description-file` metadata key is + deprecated and the `universal` wheel flag is incorrect for a Python 3-only + package. +- README now clarifies that the PyPI distribution name is `currentsapi` + (matching the 0.0.1/0.0.2 releases), documents `CurrentsAPIError` handling, + and states the supported Python versions. - Updated README with current docs link and usage examples. ### Fixed diff --git a/README.md b/README.md index e8c1a1d..b40a2f2 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,16 @@ The official Python SDK for the [Currents API](https://currentsapi.services/en/d ## Installation -Install the package from PyPI: +Install the package from PyPI. The distribution name is `currentsapi` (this +repository is `currentsapi-python`, and the Python import name is also +`currentsapi`): ```bash pip install currentsapi ``` +Python 3.8+ is supported. + ## Usage Import the client and initialize it with your API key: @@ -76,3 +80,17 @@ Get your API key at [https://currentsapi.services/en/register](https://currentsa ## License MIT License + +## Error handling + +Any non-200 API response raises `CurrentsAPIError`, which exposes the parsed +response body: + +```python +from currentsapi.client import CurrentsAPIError + +try: + api.latest_news() +except CurrentsAPIError as exc: + print(exc.status, exc.code, exc.message) +``` diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index b2445a8..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[metadata] -description-file = README.md - -[bdist_wheel] -universal=1 \ No newline at end of file diff --git a/setup.py b/setup.py index b8f2cf0..f286e8c 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,32 @@ #!/usr/bin/env python +import re +from pathlib import Path + from setuptools import setup, find_packages -with open("README.md", "r") as fh: +ROOT = Path(__file__).parent + +with (ROOT / "README.md").open(encoding="utf-8") as fh: long_description = fh.read() +with (ROOT / "currentsapi" / "__init__.py").open(encoding="utf-8") as fh: + version = re.search(r'^__version__ = "(.*?)"$', fh.read(), re.MULTILINE).group(1) + +extras_require = { + "dev": [ + "pytest", + ], +} + install_requires = [ "requests>=2.25.0", "python-dateutil>=2.8.0", ] -tests_require = [ - "pytest", -] - setup( name="currentsapi", - version="0.1.0", + version=version, author="Currents Dev", author_email="ray@currentsapi.services", license="MIT", @@ -25,7 +35,7 @@ long_description=long_description, long_description_content_type="text/markdown", install_requires=install_requires, - tests_require=tests_require, + extras_require=extras_require, description="Official Python client for the Currents API", keywords=["currentsapi", "news", "wrapper", "currents", "api"], classifiers=[