diff --git a/.github/workflows/check-and-publish.yml b/.github/workflows/check-and-publish.yml index 0184526..9e85a07 100644 --- a/.github/workflows/check-and-publish.yml +++ b/.github/workflows/check-and-publish.yml @@ -56,8 +56,8 @@ jobs: CDSAPI_URL: https://cds.climate.copernicus.eu/api/v2 CDSAPI_KEY: ${{ secrets.CDSAPI_KEY }} run: | - python setup.py develop - pip install pytest + python -m pip install --upgrade pip + install -e .[tests] pytest deploy: @@ -78,13 +78,14 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist + python -m build + twine check --strict dist/* twine upload dist/* - name: Notify climetlab diff --git a/.gitignore b/.gitignore index 46aafc5..7e29142 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,7 @@ *.grib *.nc cdsapi.egg-info +.coverage build/ +dist/ +.tox/ diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d750f33..2a3167b 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -4,9 +4,9 @@ How to develop -------------- -Install the package following README.rst and then install development dependencies:: +Install the package following README.rst and then install development dependencies (``-U`` is optional):: - $ pip install -U -r tests/requirements-dev.txt + $ pip install -U -e .[test] Unit tests can be run with `pytest `_ with:: @@ -30,9 +30,7 @@ Please ensure the coverage at least stays the same before you submit a pull requ Dependency management --------------------- -Update the `requirements-tests.txt` file with versions with:: - - pip-compile -U -o tests/requirements-tests.txt setup.py tests/requirements-tests.in # -U is optional +Update the ``tests/requirements.txt``. Release procedure diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..99434c9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,63 @@ +[build-system] +requires = ["setuptools >=62.6"] +build-backend = "setuptools.build_meta" + +[project] +name = "cdsapi" +version = "0.6.1" +description = "Python API to access the Copernicus Climate Data Store (CDS)" +readme = "README.rst" +authors = [ + {name = "ECMWF", email = "software.support@ecmwf.int"}, +] +keywords = ["MODFLOW", "groundwater", "hydrogeology"] +license = {text = "Apache-2.0"} +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Developers", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Operating System :: OS Independent", +] +requires-python = ">=3.7" +dependencies = [ + "requests >=2.5.0", + "tqdm", +] +dynamic = ["optional-dependencies"] + +[project.urls] +"Source Code" = "https://github.com/ecmwf/cdsapi" + +[tool.setuptools.dynamic.optional-dependencies.tests] +file = "tests/requirements.txt" + +[tool.setuptools.packages.find] +include = ["cdsapi", "cdsapi.*"] + +[tool.black] +line-length = 120 + +[tool.coverage.run] +branch = true + +[tool.isort] +profile = "black" +line_length = 120 + +[tool.pytest.ini_options] +norecursedirs = [ + "build", + "dist", + ".tox", + ".eggs", +] +pep8maxlinelength = 109 +mccabe-complexity = 10 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 64fb455..0000000 --- a/setup.cfg +++ /dev/null @@ -1,17 +0,0 @@ -[bdist_wheel] -universal = 1 - -[aliases] -test = pytest - -[tool:pytest] -norecursedirs = - build - dist - .tox - .eggs -pep8maxlinelength = 109 -mccabe-complexity = 10 - -[coverage:run] -branch = True diff --git a/setup.py b/setup.py deleted file mode 100644 index 1692456..0000000 --- a/setup.py +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2018 European Centre for Medium-Range Weather Forecasts (ECMWF) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# In applying this licence, ECMWF does not waive the privileges and immunities -# granted to it by virtue of its status as an intergovernmental organisation nor -# does it submit to any jurisdiction. - - -import io -import os.path - -import setuptools - - -def read(fname): - file_path = os.path.join(os.path.dirname(__file__), fname) - return io.open(file_path, encoding="utf-8").read() - - -version = "0.6.1" - - -setuptools.setup( - name="cdsapi", - version=version, - author="ECMWF", - author_email="software.support@ecmwf.int", - license="Apache 2.0", - url="https://github.com/ecmwf/cdsapi", - description="Climate Data Store API", - long_description=read("README.rst"), - packages=setuptools.find_packages(), - include_package_data=True, - install_requires=[ - "requests>=2.5.0", - "tqdm", - ], - zip_safe=True, - classifiers=[ - "Development Status :: 4 - Beta", - "Intended Audience :: Developers", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Operating System :: OS Independent", - ], -) diff --git a/tox.ini b/tox.ini index d97570f..c1c43f1 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ envlist = qc, py311, py310, py39, py38, py37, pypy3, pypy, deps [testenv] setenv = PYTHONPATH = {toxinidir} -deps = -r{toxinidir}/tests/requirements-tests.txt +deps = -r{toxinidir}/tests/requirements.txt commands = pytest -v --flakes --cache-clear --basetemp={envtmpdir} {posargs} [testenv:qc] @@ -13,12 +13,7 @@ commands = pytest -v --pep8 --mccabe --cov=cdsapi --cov-report=html --cache-clea [testenv:deps] deps = -commands = python setup.py test +commands = pytest - -[black] -line_length=120 -[isort] -profile=black [flake8] -max-line-length = 120 \ No newline at end of file +max-line-length = 120