Skip to content

Commit

Permalink
Use importlib instead of pkg_resources (#126)
Browse files Browse the repository at this point in the history
* fix migrated to latest version
* updated list of python versions in metadata
* cads-api-client to minimum version 1.4.7
* minimum python version for importlib.metadata dependancy
  • Loading branch information
EddyCMWF authored Oct 24, 2024
1 parent 9b162d6 commit d522a25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/check-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
fail-fast: false
matrix:
platform: [windows-latest, ubuntu-latest, macos-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
exclude:
- platform: macos-latest
python-version: "3.8"
Expand All @@ -58,8 +58,8 @@ jobs:

- name: Tests
env:
CDSAPI_URL: https://cds.climate.copernicus.eu/api/v2
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }}
CDSAPI_URL: https://cds.climate.copernicus.eu/api
CDSAPI_KEY: ${{ secrets.CDSAPI_KEY_2024 }}
run: |
pip install setuptools
python setup.py develop
Expand Down
5 changes: 2 additions & 3 deletions cdsapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import os
import time
import uuid
from importlib.metadata import version

import pkg_resources
import requests

try:
Expand Down Expand Up @@ -347,8 +347,7 @@ def __init__(
self.session = session
self.session.auth = tuple(self.key.split(":", 2))
self.session.headers = {
"User-Agent": "cdsapi/%s"
% pkg_resources.get_distribution("cdsapi").version,
"User-Agent": f"cdsapi/{version('cdsapi')}",
}

assert len(self.session.auth) == 2, (
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def read(fname):
long_description=read("README.rst"),
packages=setuptools.find_packages(),
include_package_data=True,
python_requires=">=3.8",
install_requires=[
"cads-api-client>=1.3.2",
"cads-api-client>=1.4.7",
"requests>=2.5.0",
"tqdm",
],
Expand All @@ -60,6 +61,7 @@ def read(fname):
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Operating System :: OS Independent",
Expand Down

0 comments on commit d522a25

Please sign in to comment.