diff --git a/.flake8 b/.flake8 new file mode 100644 index 000000000..522625f06 --- /dev/null +++ b/.flake8 @@ -0,0 +1,40 @@ +[flake8] +exclude = + .git, + docs, + build, + .eggs, + tests +ignore = + AZ100, + AZ200, + AZ300, + C, + D, + E, + F, + W503 +per-file-ignores = + xclim/core/locales.py:RST399 +rst-directives = + bibliography, + autolink-skip +rst-roles = + doc, + mod, + py:attr, + py:attribute, + py:class, + py:const, + py:data, + py:func, + py:indicator, + py:meth, + py:mod, + py:obj, + py:ref, + ref, + cite:cts, + cite:p, + cite:t, + cite:ts diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index c325fb40f..17659bb83 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -20,7 +20,6 @@ on: - pyproject.toml - requirements_dev.txt - requirements_upstream.txt - - setup.cfg - tox.ini - xclim/__init__.py @@ -43,10 +42,22 @@ jobs: run: | CURRENT_VERSION="$(grep -E '__version__' xclim/__init__.py | cut -d ' ' -f3)" echo "current_version=${CURRENT_VERSION}" + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV + - name: Install bump-my-version + run: | + python -m pip install bump-my-version - name: Bump Patch Version + if: ${{ !env.CURRENT_VERSION =~ \d+\.\d+\.\d+(-dev(\.\d+)?)?$ }} + run: | + echo "Version is stable, bumping 'patch' version" + bump-my-version bump patch + NEW_VERSION="$(grep -E '__version__' xclim/__init__.py | cut -d ' ' -f3)" + echo "new_version=${NEW_VERSION}" + - name: Bump Build Version + if: ${{ env.CURRENT_VERSION =~ \d+\.\d+\.\d+(-dev(\.\d+)?)?$ }} run: | - python -m pip install bump2version - echo "running `bump2version patch`" + echo "Development version (ends in 'dev(\.\d+)?'), bumping 'build' version" + bump-my-version bump build NEW_VERSION="$(grep -E '__version__' xclim/__init__.py | cut -d ' ' -f3)" echo "new_version=${NEW_VERSION}" - name: Push Changes diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c0d0b5468..d82707b86 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -9,7 +9,6 @@ on: - Makefile - pyproject.toml - requirements_upstream.txt - - setup.cfg - tox.ini - xclim/__init__.py - docs/**.ipynb diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 281c1438f..8eacd40c9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,7 +8,6 @@ on: - CHANGES.rst - README.rst - pyproject.toml - - setup.cfg - xclim/__init__.py pull_request: types: diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 59a587464..881d8c7c1 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -7,7 +7,6 @@ on: - CHANGES.rst - README.rst - pyproject.toml - - setup.cfg - xclim/__init__.py schedule: - cron: "0 0 * * *" # Daily “At 00:00” UTC diff --git a/.gitignore b/.gitignore index 6b0ee89bb..7b0401607 100644 --- a/.gitignore +++ b/.gitignore @@ -107,23 +107,10 @@ ENV/ .idea/ # autogenerated RestructuredText -/docs/modules.rst -/docs/xclim.core.rst -/docs/xclim.data.rst -/docs/xclim.ensembles.rst -/docs/xclim.indicators.atmos.rst -/docs/xclim.indicators.generic.rst -/docs/xclim.indicators.land.rst -/docs/xclim.indicators.rst -/docs/xclim.indicators.seaIce.rst -/docs/xclim.indices.fire.rst -/docs/xclim.indices.rst -/docs/xclim.locales.rst -/docs/xclim.rst -/docs/xclim.sdba.rst -/docs/xclim.testing.rst -/docs/xclim.testing.tests.rst -/docs/xclim.testing.tests.test_sdba.rst +docs/apidoc/modules.rst +docs/apidoc/xclim*.rst +docs/indicators.json +docs/variables.json .vscode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f5e2cc607..dcab4c479 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,6 @@ repos: rev: v4.5.0 hooks: - id: trailing-whitespace - exclude: setup.cfg - id: end-of-file-fixer exclude: '.ipynb|.github/publish-mastodon.template.md' - id: check-json @@ -33,7 +32,7 @@ repos: - id: yamllint args: [ '--config-file=.yamllint.yaml' ] - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.12.0 + rev: 23.12.1 hooks: - id: black - repo: https://github.com/PyCQA/isort @@ -41,7 +40,7 @@ repos: hooks: - id: isort - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.8 + rev: v0.1.9 hooks: - id: ruff - repo: https://github.com/pycqa/flake8 @@ -49,14 +48,14 @@ repos: hooks: - id: flake8 additional_dependencies: [ 'flake8-alphabetize', 'flake8-rst-docstrings '] - args: [ '--config=setup.cfg' ] + args: [ '--config=.flake8' ] - repo: https://github.com/nbQA-dev/nbQA rev: 1.7.1 hooks: - - id: nbqa-black - additional_dependencies: [ 'black==23.12.0' ] - id: nbqa-pyupgrade - args: [ '--py39-plus' ] + args: [ '--py38-plus' ] + - id: nbqa-black + additional_dependencies: [ 'black==23.12.1' ] - id: nbqa-isort - repo: https://github.com/kynan/nbstripout rev: 0.6.1 @@ -68,8 +67,8 @@ repos: rev: v0.3.9 hooks: - id: blackdoc + additional_dependencies: [ 'black==23.12.1' ] exclude: '(xclim/indices/__init__.py|docs/installation.rst)' - additional_dependencies: [ 'black==23.12.0' ] - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.27.3 hooks: @@ -89,5 +88,5 @@ ci: autoupdate_branch: '' autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' autoupdate_schedule: monthly - skip: [nbstripout] + skip: [ nbstripout ] submodules: false diff --git a/CHANGES.rst b/CHANGES.rst index 68bd98287..6452c8b76 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,16 +6,29 @@ v0.48 (unreleased) ------------------ Contributors to this version: Juliette Lavoie (:user:`juliettelavoie`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`), David Huard (:user:`huard`), Éric Dupuis (:user:`coxipi`). +Announcements +^^^^^^^^^^^^^ +* `xclim` now adheres to the `Semantic Versioning 2.0.0 `_ specification. (:issue:`1556`, :pull:`1569`). + New features and enhancements ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * Added uncertainty partitioning method `lafferty_sriver` from Lafferty and Sriver (2023), which can partition uncertainty related to the downscaling method. (:issue:`1497`, :pull:`1529`). * Validate YAML indicators description before trying to build module. (:issue:`1523`, :pull:`1560`). * New ``xclim.core.calendar.stack_periods`` and ``unstack_periods`` for performing ``rolling(time=...).construct(..., stride=...)`` but with non-uniform temporal periods like years or months. They replace ``xclim.sdba.processing.construct_moving_yearly_window`` and ``unpack_moving_yearly_window`` which are deprecated and will be removed in a future release. +Breaking changes +^^^^^^^^^^^^^^^^ +* `bump2version` has been replaced with `bump-my-version` to bump the version number using configurations set in the `pyproject.toml` file. (:issue:`1557`, :pull:`1569`). + Bug fixes ^^^^^^^^^ * Fixed passing ``missing=0`` to ``xclim.core.calendar.convert_calendar`` (:issue:`1562`, :pull:`1563`). +Internal changes +^^^^^^^^^^^^^^^^ +* The `flake8` configuration has been migrated from `setup.cfg` to `.flake8`; `setup.cfg` has been removed. (:pull:`1569`) +* The `bump-version.yml` workflow has been adjusted to bump the `patch` version when the last version is determined to have been a `release` version; otherwise, the `build` version is bumped. (:issue:`1557`, :pull:`1569`). + v0.47.0 (2023-12-01) -------------------- Contributors to this version: Juliette Lavoie (:user:`juliettelavoie`), Pascal Bourgault (:user:`aulemahal`), Trevor James Smith (:user:`Zeitsperre`), David Huard (:user:`huard`), Éric Dupuis (:user:`coxipi`). diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index fd5233f55..f66d96872 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -147,7 +147,7 @@ Ready to contribute? Here's how to set up `xclim` for local development. $ black --check xclim tests $ isort --check xclim tests $ ruff xclim tests - $ flake8 --config=setup.cfg xclim tests + $ flake8 --config=.flake8 xclim tests $ nbqa black --check docs $ nbqa isort --check docs $ blackdoc --check --exclude=xclim/indices/__init__.py xclim diff --git a/Makefile b/Makefile index d78c50063..7146a99ed 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ lint: ## check style with flake8 and black black --check xclim tests isort --check xclim tests ruff xclim tests - flake8 --config=setup.cfg xclim tests + flake8 --config=.flake8 xclim tests nbqa black --check docs blackdoc --check --exclude=xclim/indices/__init__.py xclim blackdoc --check docs diff --git a/environment.yml b/environment.yml index 98fa917f1..32681b595 100644 --- a/environment.yml +++ b/environment.yml @@ -29,7 +29,7 @@ dependencies: # Testing and development dependencies - black >=22.12 - blackdoc - - bump2version + - bump-my-version - cairosvg - coverage - distributed >=2.0 diff --git a/pyproject.toml b/pyproject.toml index baaca68a4..b375736a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ dev = [ # Dev tools and testing "black >=23.12.0", "blackdoc", - "bump2version", + "bump-my-version", "coverage[toml]", "flake8", "flake8-alphabetize", @@ -120,6 +120,32 @@ target-version = [ "py312" ] +[tool.bumpversion] +current_version = "0.47.4-beta" +commit = true +tag = false +allow_dirty = true +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)(\\-(?P[a-z]+)(\\.(?P\\d+)))?" +serialize = [ + "{major}.{minor}.{patch}-{release}.{build}", + "{major}.{minor}.{patch}" +] + +[[tool.bumpversion.files]] +filename = "xclim/__init__.py" +search = "__version__ = \"{current_version}\"" +replace = "__version__ = \"{new_version}\"" + +[tool.bumpversion.parts.build] +independent = false + +[tool.bumpversion.parts.release] +optional_value = "release" +values = [ + "dev", + "release" +] + [tool.coverage.run] relative_files = true omit = ["tests/*.py"] @@ -142,7 +168,6 @@ include = [ "docs/make.bat", "docs/notebooks/_finder.py", "requirements_upstream.txt", - "setup.cfg", "tests/**/*.py", "tests/**/*.txt", "tox.ini", diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bf840465d..000000000 --- a/setup.cfg +++ /dev/null @@ -1,59 +0,0 @@ -[bumpversion] -current_version = 0.47.4-beta -commit = True -tag = False -parse = (?P\d+)\.(?P\d+).(?P\d+)(\-(?P[a-z]+))? -serialize = - {major}.{minor}.{patch}-{release} - {major}.{minor}.{patch} - -[bumpversion:part:release] -optional_value = gamma -values = - beta - gamma - -[bumpversion:file:xclim/__init__.py] -search = __version__ = "{current_version}" -replace = __version__ = "{new_version}" - -[flake8] -exclude = - .git, - docs, - build, - .eggs, - tests -ignore = - AZ100, - AZ200, - AZ300, - C, - D, - E, - F, - W503 -per-file-ignores = - xclim/core/locales.py:RST399 -rst-directives = - bibliography, - autolink-skip -rst-roles = - doc, - mod, - py:attr, - py:attribute, - py:class, - py:const, - py:data, - py:func, - py:indicator, - py:meth, - py:mod, - py:obj, - py:ref, - ref, - cite:cts, - cite:p, - cite:t, - cite:ts diff --git a/tox.ini b/tox.ini index 7b5bcd918..cafce835f 100644 --- a/tox.ini +++ b/tox.ini @@ -34,7 +34,7 @@ commands = black --check xclim tests isort --check xclim tests ruff xclim tests - flake8 --config=setup.cfg xclim tests + flake8 --config=.flake8 xclim tests nbqa black --check docs blackdoc --check --exclude=xclim/indices/__init__.py xclim blackdoc --check docs