From 1dc5903396775a7c7dd3da7b259f03b88739dc51 Mon Sep 17 00:00:00 2001 From: Autumn-Atlas Date: Wed, 9 Sep 2026 11:12:06 +0800 Subject: [PATCH 1/4] fix(packaging): single-source version and drop obsolete setup.cfg - setup.py now reads __version__ from currentsapi/__init__.py so the version can no longer drift between the two files. - Replace deprecated tests_require with an extras_require 'dev' extra. - Remove setup.cfg: description-file is deprecated and the universal wheel flag is wrong for a Python 3-only package (wheels now build as py3-none-any). --- setup.cfg | 5 ----- setup.py | 25 ++++++++++++++++++++----- 2 files changed, 20 insertions(+), 10 deletions(-) delete mode 100644 setup.cfg 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..43d13d5 100644 --- a/setup.py +++ b/setup.py @@ -1,22 +1,37 @@ #!/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) + install_requires = [ "requests>=2.25.0", "python-dateutil>=2.8.0", ] -tests_require = [ - "pytest", +extras_require = { + "dev": [ + "pytest", + ], +} + +install_requires = [ + "requests>=2.25.0", + "python-dateutil>=2.8.0", ] setup( name="currentsapi", - version="0.1.0", + version=version, author="Currents Dev", author_email="ray@currentsapi.services", license="MIT", @@ -25,7 +40,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=[ From 1e4c2ef24ab1b5f7d27a8713297e995ff00fcac4 Mon Sep 17 00:00:00 2001 From: Autumn-Atlas Date: Wed, 9 Sep 2026 11:12:06 +0800 Subject: [PATCH 2/4] docs(readme): clarify distribution name, python support, and error handling - State that the PyPI distribution name is 'currentsapi' while the repository is 'currentsapi-python', matching the 0.0.1/0.0.2 releases. - Note Python 3.8+ support (mirrors python_requires). - Document CurrentsAPIError and its status/code/message accessors. --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) 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) +``` From 9ba93b6adf930b3ad4de0545d9a15f81b50387cd Mon Sep 17 00:00:00 2001 From: Autumn-Atlas Date: Wed, 9 Sep 2026 11:12:06 +0800 Subject: [PATCH 3/4] docs(changelog): note packaging alignment for 0.1.0 --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 From a4e33e78d0e8b930b39f7f001f25f59dd169c781 Mon Sep 17 00:00:00 2001 From: Autumn-Atlas Date: Wed, 9 Sep 2026 12:53:15 +0800 Subject: [PATCH 4/4] fix(packaging): remove duplicated install_requires assignment --- setup.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/setup.py b/setup.py index 43d13d5..f286e8c 100644 --- a/setup.py +++ b/setup.py @@ -13,11 +13,6 @@ with (ROOT / "currentsapi" / "__init__.py").open(encoding="utf-8") as fh: version = re.search(r'^__version__ = "(.*?)"$', fh.read(), re.MULTILINE).group(1) -install_requires = [ - "requests>=2.25.0", - "python-dateutil>=2.8.0", -] - extras_require = { "dev": [ "pytest",