Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyproject.toml instead of setup.py/setup.cfg #2540

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ previous command. To only run tests from a single file, run the command
pytest tests/unit/test_some_file.py

If you would like to avoid loading the default pytest configuration from
`setup.cfg <https://github.com/ESMValGroup/ESMValCore/blob/main/setup.cfg>`_
`pyproject.toml <https://github.com/ESMValGroup/ESMValCore/blob/main/pyproject.toml>`_
because this can be a bit slow for running just a few tests, use

.. code-block:: bash
Expand Down Expand Up @@ -653,7 +653,7 @@ the following files:
- ``environment.yml``
contains all the development dependencies; these are all from
`conda-forge <https://conda-forge.org/>`_
- ``setup.py``
- ``pyproject.toml``
contains all Python dependencies, regardless of their installation source

Note that packages may have a different name on
Expand Down
7 changes: 4 additions & 3 deletions esmvalcore/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,10 @@

returncode = None

with resource_usage_logger(process.pid, self.resource_log), open(
self.log, "ab"
) as log:
with (

Check warning on line 612 in esmvalcore/_task.py

View check run for this annotation

Codecov / codecov/patch

esmvalcore/_task.py#L612

Added line #L612 was not covered by tests
resource_usage_logger(process.pid, self.resource_log),
open(self.log, "ab") as log,
):
last_line = [""]
while returncode is None:
returncode = process.poll()
Expand Down
161 changes: 160 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,121 @@
[build-system]
requires = ["setuptools >= 40.6.0", "wheel", "setuptools_scm>=6.2"]
requires = [
"setuptools >= 40.6.0",
"setuptools_scm>=6.2",
]
build-backend = "setuptools.build_meta"

[project]
authors = [
{name = "ESMValTool Development Team", email = "[email protected]"}
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Atmospheric Science",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Hydrology",
"Topic :: Scientific/Engineering :: Physics",
]
dynamic = [
"readme",
"version",
]
description = "A community tool for pre-processing data from Earth system models in CMIP and running analysis scripts"
dependencies = [
"cartopy",
"cf-units",
"dask[array,distributed]!=2024.8.0", # ESMValCore/issues/2503
"dask-jobqueue",
"esgf-pyclient>=0.3.1",
"esmf-regrid>=0.11.0",
"esmpy!=8.1.0", # not on PyPI
"filelock",
"fiona",
"fire",
"geopy",
"humanfriendly",
"iris-grib",
"isodate",
"jinja2",
"nc-time-axis", # needed by iris.plot
"nested-lookup",
"netCDF4",
"numpy!=1.24.3,<2.0.0", # avoid pulling 2.0.0rc1
"packaging",
"pandas",
"pillow",
"prov",
"psutil",
"py-cordex",
"pybtex",
"pyyaml",
"requests",
"scipy>=1.6",
"scitools-iris>=3.10.0",
"shapely>=2.0.0",
"stratify>=0.3",
"yamale",
]
license = {text = "Apache License, Version 2.0"}
name = "ESMValCore"
requires-python = ">=3.10"

[project.optional-dependencies]
test = [
"pytest>6.0.0",
"pytest-cov>=2.10.1",
"pytest-env",
"pytest-html!=2.1.0",
"pytest-metadata>=1.5.1",
"pytest-mock",
"pytest-xdist",
"ESMValTool_sample_data==0.0.3",
]
doc = [
"autodocsumm>=0.2.2",
"ipython",
"nbsphinx",
"sphinx>=6.1.3",
"pydata_sphinx_theme",
]
develop = [
"esmvalcore[test,doc]",
"pre-commit",
"pylint",
"pydocstyle",
"vprof",
]

[project.scripts]
esmvaltool = "esmvalcore._main:run"

[project.urls]
Code = "https://github.com/ESMValGroup/ESMValCore"
Community = "https://github.com/ESMValGroup/Community"
Documentation = "https://docs.esmvaltool.org"
Homepage = "https://esmvaltool.org"
Issues = "https://github.com/ESMValGroup/ESMValCore/issues"

[tool.setuptools]
include-package-data = true
license-files = ["LICENSE"]
packages = ["esmvalcore"]
zip-safe = false

[tool.setuptools.dynamic]
readme = {file = "README.md", content-type = "text/markdown"}

[tool.setuptools_scm]
version_scheme = "release-branch-semver"

Expand Down Expand Up @@ -29,6 +143,41 @@ disable = [
"line-too-long", # Disable line-too-long as this is taken care of by the formatter.
"locally-disabled", # Disable messages about disabling checks
]

[tool.pytest.ini_options]
addopts = [
"-ra",
"--strict-config",
"--strict-markers",
"--doctest-modules",
"--ignore=esmvalcore/cmor/tables/",
"--cov",
"--cov-report=xml:test-reports/coverage.xml",
"--cov-report=html:test-reports/coverage_html",
"--html=test-reports/report.html",
]
log_cli_level = "INFO"
env = {MPLBACKEND = "Agg"}
log_level = "WARNING"
minversion = "6"
markers = [
"installation: Test requires installation of dependencies",
"use_sample_data: Run functional tests using real data",
]
testpaths = ["tests"]
xfail_strict = true

[tool.coverage.run]
parallel = true
source = ["esmvalcore"]

[tool.coverage.report]
exclude_lines = [
"pragma: no cover",
"if __name__ == .__main__.:",
"if TYPE_CHECKING:",
]

[tool.ruff]
line-length = 79
[tool.ruff.lint]
Expand All @@ -44,3 +193,13 @@ ignore = [
]
[tool.ruff.lint.isort]
known-first-party = ["esmvalcore"]

[tool.mypy]
# See https://mypy.readthedocs.io/en/stable/config_file.html
ignore_missing_imports = true
enable_error_code = [
"truthy-bool",
]

[tool.pydocstyle]
convention = "numpy"
32 changes: 0 additions & 32 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
[tool:pytest]
addopts =
--doctest-modules
--ignore=esmvalcore/cmor/tables/
--cov=esmvalcore
--cov-report=xml:test-reports/coverage.xml
--cov-report=html:test-reports/coverage_html
--html=test-reports/report.html
env =
MPLBACKEND = Agg
log_level = WARNING
markers =
installation: Test requires installation of dependencies
use_sample_data: Run functional tests using real data

[coverage:run]
parallel = true
[coverage:report]
exclude_lines =
pragma: no cover
if __name__ == .__main__.:
if TYPE_CHECKING:

[pycodestyle]
# ignore rules that conflict with ruff formatter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love the outcome of this issue, that was proposing support for pyproject.toml 🤣 PyCQA/pycodestyle#813

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to drop pycodestyle as soon as we're using ruff for linting too.

# E203: https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#slices
# E501: https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
# W503: https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
ignore = E203,E501,W503

[pydocstyle]
convention = numpy

[mypy]
# see mypy.readthedocs.io/en/stable/command_line.html
python_version = 3.12
ignore_missing_imports = True
files = esmvalcore, tests
Loading