From f5cda456dbf065bc4e545e25ebcb9219145e9e0c Mon Sep 17 00:00:00 2001 From: Lars Buntemeyer Date: Mon, 6 Nov 2023 15:10:53 +0100 Subject: [PATCH] update build sytem to pyproject.toml --- index_calculator/__init__.py | 12 ++- pyproject.toml | 139 +++++++++++++++++++++++++++++++++++ setup.cfg | 21 ------ setup.py | 67 ----------------- tox.ini | 25 ------- 5 files changed, 150 insertions(+), 114 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tox.ini diff --git a/index_calculator/__init__.py b/index_calculator/__init__.py index db34e75..bce2a27 100644 --- a/index_calculator/__init__.py +++ b/index_calculator/__init__.py @@ -2,7 +2,8 @@ __author__ = """Ludwig Lierhammer""" __email__ = "ludwig.lierhammer@dwd.de" -__version__ = "0.11.0" + +import pkg_resources from ._outputwriter import OutputWriter as outputwriter from ._postprocessing import PostProcessing as postprocessing @@ -16,6 +17,15 @@ from ._tables import xjson # noqa from .index_calculator import IndexCalculator as index_calculator + +try: + __version__ = pkg_resources.get_distribution("index_calculator").version +except Exception: + # Local copy or not installed with setuptools. + # Disable minimum version checks on downstream libraries. + __version__ = "999" + + preprocessing.__module__ = __name__ preprocessing.__name__ = "preprocessing" processing.__module__ = __name__ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..979dab9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,139 @@ +[project] +name = "index_calculator" +description="Python index-calculator is an xclim wrapper" +readme = "README.rst" +requires-python = ">=3.9" +license = {file = "LICENSE"} +keywords = ["index_calculator"] +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "xarray", + "dask", + "xclim", + "pyhomogenize>=0.5.1", + "pint>=0.1", + "pooch" +] +dynamic = ["version"] + +[project.urls] +homepage = "https://index-calculator.readthedocs.io" +documentation = "https://index-calculator.readthedocs.io" +repository = "https://github.com/ludwiglierhammer/index_calculator.git" +changelog = "https://index-calculator.readthedocs.io/en/latest/history.html" + +[build-system] +requires = [ + "xarray", + "setuptools>=45", + "wheel", + "setuptools_scm[toml]>=6.2", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools] +packages = ["index_calculator"] + +[tool.setuptools_scm] +fallback_version = "999" +write_to = "index_calculator/_version.py" +write_to_template= '__version__ = "{version}"' +tag_regex= "^(?Pv)?(?P[^\\+]+)(?P.*)?$" + +[tool.black] +target-version = ["py38"] + +[tool.ruff] +target-version = "py38" +builtins = ["ellipsis"] +exclude = [ + ".eggs", + "doc", +] +# E402: module level import not at top of file +# E501: line too long - let black worry about that +# E731: do not assign a lambda expression, use a def +ignore = [ + "E203", + "E402", + "E501", + "E731", +] +select = [ + # Pyflakes + "F", + # Pycodestyle + "E", + "W", + # isort + "I", + # Pyupgrade + "UP", +] + +[tool.ruff.isort] +known-first-party = ["index_calculator"] +known-third-party = [ + "dask", + "matplotlib", + "numpy", + "pandas", + "pint", + "pkg_resources", + "pytest", + "setuptools", + "sphinx_autosummary_accessors", + "xarray" +] + +[tool.pytest] +python_files = "test_*.py" +testpaths = ["./tests"] + +[tool.rstcheck] +report_level = "WARNING" +ignore_roles = [ + "pr", + "issue", +] +ignore_directives = [ + "ipython", + "autodata", + "autosummary", +] + +[tool.nbqa.md] +mdformat = true + +[tool.mypy] +exclude = "doc|flycheck" +files = "index_calculator/" +show_error_codes = true +warn_unused_ignores = true + +[[tool.mypy.overrides]] +module=[ + "cftime", + "pandas", + "pooch", + "pint", + "matplotlib", + "pytest", + "shapely.geometry", + "xarray.core.pycompat", +] +ignore_missing_imports = true + +[tool.coverage.run] +omit = [ + "test.py" +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 01c1278..0000000 --- a/setup.cfg +++ /dev/null @@ -1,21 +0,0 @@ -[flake8] -ignore= - # whitespace before ':' - doesn't work well with black - E203 - # module level import not at top of file - E402 - # line too long - let black worry about that - E501 - # do not assign a lambda expression, use a def - E731 - # line break before binary operator - W503 -exclude= - build - docs - .git - -[isort] -profile = black -skip_gitignore = true -force_to_top = true diff --git a/setup.py b/setup.py deleted file mode 100644 index f1f0e1a..0000000 --- a/setup.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env python - -"""The setup script.""" - -from setuptools import find_packages, setup - -with open("README.rst") as readme_file: - readme = readme_file.read() - -with open("HISTORY.rst") as history_file: - history = history_file.read() - -with open("index_calculator/__init__.py") as init_file: - lines = init_file.read().strip().replace(" ", "").split("\n") - for line in lines: - if "__version__" in line: - __version__ = line.split("=")[-1] - __version__ = __version__.replace('"', "") - break - - -def _read_txt(txt_file): - return open(txt_file).read().strip().split("\n") - - -requirements = _read_txt("ci/requirements/requirements.txt") - -setup_requirements = _read_txt("ci/requirements/requirements_dev.txt") - -test_requirements = [] - -setup( - author="Ludwig Lierhammer", - author_email="ludwig.lierhammer@hereon.de", - python_requires=">=3.9", - classifiers=[ - "Development Status :: 2 - Pre-Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - description="Python index-calculator is an xclim wrapper" - "to calculate climate indices from CMORized netCDF files.", - entry_points={ - "console_scripts": [ - "index_calculator=index_calculator.cli:main", - ], - }, - install_requires=requirements, - license="MIT license", - long_description=readme + "\n\n" + history, - include_package_data=True, - keywords="index_calculator", - name="index_calculator", - packages=find_packages(include=["index_calculator", "index_calculator.*"]), - package_data={"index_calculator": ["*/*.nc", "*/*.json"]}, - setup_requires=setup_requirements, - test_suite="tests", - tests_require=test_requirements, - url="https://github.com/ludwiglierhammer/index_calculator", - version=__version__, - zip_safe=False, -) diff --git a/tox.ini b/tox.ini deleted file mode 100644 index d7f1f13..0000000 --- a/tox.ini +++ /dev/null @@ -1,25 +0,0 @@ -[tox] -envlist = py36, py37, py38, flake8 - -[travis] -python = - 3.8: py38 - 3.7: py37 - 3.6: py36 - -[testenv:flake8] -basepython = python -deps = flake8 -commands = flake8 index_calculator tests - -[testenv] -setenv = - PYTHONPATH = {toxinidir} -deps = - -r{toxinidir}/requirements_dev.txt -; If you want to make tox run the tests with the same versions, create a -; requirements.txt with the pinned versions and uncomment the following line: -; -r{toxinidir}/requirements.txt -commands = - pip install -U pip - pytest --basetemp={envtmpdir}