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

Adopt PEP 517 and PEP 621, use raven-hydro package #278

Merged
merged 70 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2dfcd0f
update pre-commit hooks
Zeitsperre Apr 19, 2023
c1f547d
remove MANIFEST.in
Zeitsperre Apr 19, 2023
d41b6e4
remove requirement files
Zeitsperre Apr 19, 2023
5b25eba
update dynamic package fields
Zeitsperre Apr 19, 2023
102870f
update setup.cfg for new structure
Zeitsperre Apr 19, 2023
d939260
use relative imports to deal with import resolution issues
Zeitsperre Apr 19, 2023
2dece38
replace setup.py with pyproject.toml
Zeitsperre Apr 19, 2023
c34ccd9
note that clisops is mocked
Zeitsperre Apr 19, 2023
baa3385
readability
Zeitsperre Apr 19, 2023
46ff437
fix CLI entrypoint
Zeitsperre Apr 19, 2023
bb3bbd8
update installation instructions and remove tox/Makefile calls to obs…
Zeitsperre Apr 19, 2023
503395b
remove check-manifest skip
Zeitsperre Apr 19, 2023
79b482c
add pytest markers
Zeitsperre Apr 19, 2023
58b23d0
add gdal to RtD build
Zeitsperre Apr 19, 2023
94c9864
comment out tox GDAL compile
Zeitsperre Apr 19, 2023
f61235b
Merge branch 'master' into adopt_pep517-621
Zeitsperre May 3, 2023
9c5ed30
update xclim, simplify build procedure
Zeitsperre May 9, 2023
859a3e4
Merge branch 'master' into adopt_pep517-621
Zeitsperre May 9, 2023
f934ec1
Update pyproject.toml
Zeitsperre May 10, 2023
b6fcbba
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 10, 2023
31175e1
WIP - add raven-hydro to tox build
Zeitsperre May 10, 2023
48ba8ad
try a workaround to not have ReadTheDocs run `--upgrade-strategy eager`
Zeitsperre May 12, 2023
c314021
dependency management
Zeitsperre May 12, 2023
f3d59e6
GDAL
Zeitsperre May 12, 2023
6d32f07
typo
Zeitsperre May 12, 2023
3b19b0c
fix deprecations
Zeitsperre May 12, 2023
b2d1412
typos
Zeitsperre May 12, 2023
c866eb5
add pooch
Zeitsperre May 12, 2023
b83cdc4
simplify installation process further
Zeitsperre May 12, 2023
1fae833
add a windows build
Zeitsperre May 12, 2023
db9795e
synchronize and simplify
Zeitsperre May 12, 2023
bc3a3b7
add a macOS pip build
Zeitsperre May 12, 2023
1f64551
fix sed call
Zeitsperre May 12, 2023
8c6a500
fix owslib version
Zeitsperre May 12, 2023
5b4a99f
fix owslib version
Zeitsperre May 12, 2023
c1b2cd1
tweaks
Zeitsperre May 12, 2023
a3619f0
tweaks
Zeitsperre May 12, 2023
21513fd
update to newest geopandas API
Zeitsperre May 15, 2023
8bdbcd8
add pyogrio
Zeitsperre May 15, 2023
a7c3d4c
remove lots of redundant dependencies, make mention to update install…
Zeitsperre May 19, 2023
6d748aa
update contributor documentation
Zeitsperre May 19, 2023
59c2bff
port remaining enhancements from experimental branch
Zeitsperre May 19, 2023
be6fe55
update installation instructions
Zeitsperre May 23, 2023
ebb5729
add raven-hydro to requirements
Zeitsperre May 23, 2023
17fc9fa
add raven-hydro to requirements, pin pydantic to 1.10.8+
Zeitsperre May 23, 2023
6065713
drop python3.9, install raven-hydro in conda by sdist
Zeitsperre May 23, 2023
c75901e
==
Zeitsperre May 23, 2023
2df1f85
do not drop Python3.8, build raven-hydro from sources always
Zeitsperre May 23, 2023
f6c256e
use raven-hydro conda package
Zeitsperre May 24, 2023
6cc0c1d
update CI
Zeitsperre May 24, 2023
4dad1fe
install conda, force cache update
Zeitsperre May 24, 2023
312ba8d
try Python3.10
Zeitsperre May 24, 2023
f053d7a
Merge branch 'master' into adopt_pep517-621
huard May 24, 2023
d72f712
install climpred via PyPI
Zeitsperre May 24, 2023
4de60f5
Add a macos conda build
Zeitsperre May 24, 2023
870af30
pin netcdf4 at or below 1.6.0
Zeitsperre May 24, 2023
51bbc7f
pin netcdf4 below 1.6.3
Zeitsperre May 24, 2023
78b470f
unable to pin netcdf, constrain python
Zeitsperre May 24, 2023
ad5b88d
mark dap test as online
Zeitsperre May 24, 2023
575d854
use a context manager to access netcdf data within a session-scope py…
Zeitsperre May 24, 2023
7785bf5
try context manager approach
Zeitsperre May 24, 2023
b0806b5
adjust test
Zeitsperre May 24, 2023
d10039c
adjust CI - drop windows
Zeitsperre May 24, 2023
9a84f58
update CI for more build coverage
Zeitsperre May 25, 2023
1617fb1
update conda environment information
Zeitsperre May 25, 2023
153e61d
Update documentation to reflect changes
Zeitsperre May 25, 2023
75b51c9
attempt to fix domain lookup bug
Zeitsperre May 25, 2023
698b740
pin raven-hydro to v0.2.1
Zeitsperre May 25, 2023
85b5c64
allow errors for macOS
Zeitsperre May 25, 2023
8701053
allow errors for macOS on PyPI
Zeitsperre May 25, 2023
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
83 changes: 66 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,61 +30,110 @@ jobs:
run: tox -e black

pip:
name: Pip with Python${{ matrix.python-version }}
name: Python${{ matrix.python-version }} (${{ matrix.os }})
needs: black
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- tox-env: py38
python-version: "3.8"
- tox-env: py39-numpy
os: ubuntu-latest
allow-errors: false
- tox-env: py39
python-version: "3.9"
os: ubuntu-latest
allow-errors: false
- tox-env: py310
python-version: "3.10"
os: ubuntu-latest
allow-errors: false
- tox-env: py311
python-version: "3.11"
os: ubuntu-latest
allow-errors: false
- tox-env: py310
python-version: "3.10"
os: macos-latest
allow-errors: true
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install GDAL

- name: Install GDAL (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install libgdal-dev
- name: Install tox and setuptools
- name: Install GDAL (macOS)
if: matrix.os == 'macos-latest'
uses: tecolicom/actions-use-homebrew-tools@v1
with:
tools: gdal
cache: yes
- name: Set GDAL_VERSION (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
echo "GDAL_VERSION=$(gdal-config --version)" >> $GITHUB_ENV
- name: Set GDAL_VERSION (macOS)
if: matrix.os == 'macos-latest'
run: |
echo "GDAL_VERSION=$(gdalinfo --version | awk '{print $2}' | sed s'/.$//')" >> $GITHUB_ENV

- name: Install tox
run: |
pip install tox~=4.0
pip install --upgrade "setuptools<65.6"
- name: Test with tox and report coverage
run: env GDAL_VERSION="$(gdal-config --version)" tox -e ${{ matrix.tox-env }}
run: |
python3 -m tox -e ${{ matrix.tox-env }}
continue-on-error: ${{ matrix.allow-errors }}
env:
LD_PRELOAD: /lib/x86_64-linux-gnu/libstdc++.so.6 # :"$LD_PRELOAD"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: run-${{ matrix.tox-env }}
COVERALLS_PARALLEL: true

conda:
name: Conda
name: Python${{ matrix.python-version }} (${{ matrix.os }}) (Conda)
needs: black
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: macos-latest
python-version: "3.9"
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v3
- name: Setup Conda (Micromamba) with Python3.9
uses: mamba-org/provision-with-micromamba@main
- name: Patch Environment File
if: matrix.os == 'windows-latest'
run: |
sed -i 's/climpred >=2.2.0/xesmf/' environment.yml
- name: Setup Conda (Micromamba) with Python${{ matrix.python-version }}
uses: mamba-org/setup-micromamba@v1
with:
cache-downloads: true
cache-environment: true
environment-file: environment.yml
extra-specs: |
mamba
pip<23.1
python=3.9
create-args: >-
conda
python=${{ matrix.python-version }}
- name: Conda and Mamba versions
run: |
mamba --version
conda --version
echo "micromamba: $(micromamba --version)"
- name: Install RavenPy
run: |
pip install -e ".[dev]"
Expand Down
33 changes: 14 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,33 @@ repos:
rev: v3.4.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]
args: [ '--py38-plus' ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: .rvc|.rvh|.rvi|.rvp|.rvt|.tpl|.txt|setup.cfg
- id: end-of-file-fixer
exclude: .ipynb|.rvc|.rvh|.rvi|.rvp|.rvt|.tpl|.txt
- id: check-json
- id: check-toml
- id: check-yaml
args: [ --allow-multiple-documents ]
args: [ '--allow-multiple-documents' ]
- id: debug-statements
- id: pretty-format-json
args: [ '--autofix', '--no-ensure-ascii', '--no-sort-keys' ]
- id: debug-statements
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: rst-inline-touching-normal
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.0
hooks:
- id: toml-sort-fix
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
exclude: ^docs/
args: [ --target-version=py38 ]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
Expand All @@ -40,19 +42,16 @@ repos:
rev: 5.12.0
hooks:
- id: isort
args: [ --settings-file=setup.cfg ]
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-pyupgrade
args: [ --py38-plus ]
additional_dependencies: [ pyupgrade==3.3.1 ]
additional_dependencies: [ 'pyupgrade==3.3.1' ]
- id: nbqa-black
args: [ --target-version=py38 ]
additional_dependencies: [ black==23.3.0 ]
additional_dependencies: [ 'black==23.3.0' ]
- id: nbqa-isort
args: [ --settings-file=setup.cfg ]
additional_dependencies: [ isort==5.12.0 ]
additional_dependencies: [ 'isort==5.12.0' ]
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
Expand All @@ -62,16 +61,12 @@ repos:
rev: v0.3.8
hooks:
- id: blackdoc
additional_dependencies: [ black==23.3.0 ]
additional_dependencies: [ 'black==23.3.0' ]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
hooks:
- id: yamllint
args: [ '--config-file', '.yamllint.yaml' ]
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
args: [ '--config-file=.yamllint.yaml' ]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.0
hooks:
Expand All @@ -91,5 +86,5 @@ ci:
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [ check-manifest ]
skip: [ ]
submodules: false
16 changes: 9 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ build:
tools:
python: "mambaforge-4.10"
jobs:
post_install:
- pip install .[docs,gis]
pre_build:
- sphinx-apidoc -o docs/apidoc --private --module-first ravenpy
- sphinx-build -b linkcheck docs/ _build/linkcheck
- sphinx-build -b linkcheck docs/ _build/linkcheck || true

formats: all

conda:
environment: environment-rtd.yml

python:
install:
- method: pip
path: .
extra_requirements:
- dev
#python:
# install:
# - method: pip
# path: .
# extra_requirements:
# - dev
57 changes: 42 additions & 15 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Ready to contribute? Here's how to set up `ravenpy` for local development.
$ pre-commit install

Special style and formatting checks will be run when you commit your changes. You
can always run the hooks on their own with:
can always run the hooks on their own with::

$ pre-commit run -a

Expand Down Expand Up @@ -119,7 +119,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.8, 3.9, and 3.10. Check
3. The pull request should work for Python 3.8, 3.9, 3.10, and 3.11. Check
https://github.com/CSHS-CWRA/RavenPy/actions/workflows/main.yml
and make sure that the tests pass for all supported Python versions.

Expand All @@ -128,7 +128,7 @@ Tips

To run a subset of tests::

$ pytest tests.test_ravenpy
$ pytest tests.test_ravenpy


Versioning/Tagging
Expand All @@ -138,31 +138,43 @@ A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::

$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags
$ bumpversion patch # possible: major / minor / patch
$ git push
$ git push --tags

Packaging
---------

When a new version has been minted (features have been successfully integrated test coverage and stability is adequate),
maintainers should update the pip-installable package (wheel and source release) on PyPI as well as the binary on conda-forge.

The simple approach
The Automated Approach
~~~~~~~~~~~~~~~~~~~~~~

The simplest way to package `ravenpy` is to "publish" a version on GitHuh. GitHub CI Actions are presently configured to build the library and publish the packages on PyPI automatically.

Tagged versions will trigger a GitHub Workflow (`tag-testpypi.yml`) that will attempt to build and publish the release on `TestPyPI <https://test.pypi.org>`_.

.. note::
Should this step fail, changes may be needed in the package; Be sure to remove this tag on GitHub and locally, address any existing problems, and recreate the tag.

To upload a new version to `PyPI <https://pypi.org/>`_, simply create a new "Published" release version on GitHub to trigger the upload workflow (`publish-pypi.yml`). When publishing on GitHub, the maintainer can either set the release notes manually (based on the `HISTORY.rst`), or set GitHub to generate release notes automatically. The choice of method is up to the maintainer.

.. warning::
A published version on TestPyPI/PyPI can never be overwritten. Be sure to verify that the package published at https://test.pypi.org/project/ravenpy/ matches expectations before publishing a release version on GitHub.

The Manual Approach
~~~~~~~~~~~~~~~~~~~

The simplest approach to packaging for general support (pip wheels) requires the following packages installed:
* setuptools
* wheel
* twine
The manual approach to library packaging for general support (pip wheels) requires that the `flit <https://flit.pypa.io/en/stable/index.html>`_ library is installed.

From the command line on your Linux distribution, simply run the following from the clone's main dev branch::

# To build the packages (sources and wheel)
$ python setup.py sdist bdist_wheel
$ flit build

# To upload to PyPI
$ twine upload dist/*
$ flit publish

The new version based off of the version checked out will now be available via `pip` (`$ pip install ravenpy`).

Expand All @@ -177,8 +189,23 @@ In order to prepare an initial release on conda-forge, we *strongly* suggest con
* https://github.com/conda-forge/staged-recipes

Before updating the main conda-forge recipe, we echo the conda-forge documentation and *strongly* suggest performing the following checks:
* Ensure that dependencies and dependency versions correspond with those of the tagged version, with open or pinned versions for the `host` requirements.
* If possible, configure tests within the conda-forge build CI (e.g. `imports: ravenpy`, `commands: pytest ravenpy`)
* Ensure that dependencies and dependency versions correspond with those of the PyPI published version, with open or pinned versions for the `host` requirements.
* If possible, configure tests within the conda-forge build CI, e.g.:

.. code-block:: yaml

test:
source_files:
- tests
requires:
- pip
- pytest
- pytest-xdist
imports:
- ravenpy
commands:
- pip check
- pytest

Subsequent releases
^^^^^^^^^^^^^^^^^^^
Expand Down
10 changes: 10 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
History
=======

0.12.0 (2023-05-25)
-------------------

* Ravenpy now employs a new method for installing the Raven model using the `raven-hydro <https://github.com/Ouranosinc/raven-hydro>`_ python package (based on `scikit-build-core`).
* Replaced `setup.py`, `requirements.txt`, and `Manifest.in` for `PEP 517 <https://peps.python.org/pep-0517>`_ compliance (`pyproject.toml`) using the flit backend.
* Dealt with an import-based error that occurred due to the sequence in which modules are loaded at import (attempting to call ravenpy before it is installed).
* Updated pre-commit hooks to include formatters and checkers for TOML files.
* The build recipes no longer build on each other, so when installing the dev or docs recipe, you must also install the gis recipe.
* Updated the GeoServer API calls to work with the GeoPandas v0.13.0.

0.11.0 (2023-02-16)
-------------------

Expand Down
Loading