Skip to content

Commit

Permalink
Prepare v0.17 (numpy>=2.0) (#310)
Browse files Browse the repository at this point in the history
* Build extensions with numpy 2

* Build extensions with numpy 2

* Update metapackage

* Rebuild with numpy 2.0.2

* Update readme

* Update for numpy 2

* Update C files

* Update for numpy 2

* Cleanup
  • Loading branch information
wpreimes authored Nov 13, 2024
1 parent ad981a2 commit 25e8dfa
Show file tree
Hide file tree
Showing 13 changed files with 9,056 additions and 7,187 deletions.
46 changes: 22 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# For more information see:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Automated Tests
name: CI/CD

on:
push:
Expand All @@ -19,24 +19,24 @@ jobs:
# as we build C extension for users to download, we want to include as many python versions
# and OS versions as possible (especially windows to create .whl packages,
# see step "Create wheel and dist package")
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
os: ["ubuntu-latest", "windows-latest"]
python-version: ['3.9', '3.10', '3.11', '3.12']
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
name: py${{ matrix.python-version }} @ ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
with:
submodules: true # does not work with self-hosted testdata
submodules: true
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
activate-environment: pytesmo # todo: must match with name in environment.yml
mamba-version: "*"
activate-environment: pytesmo
channel-priority: flexible
auto-activate-base: false
- name: Print Infos
shell: bash -l {0}
Expand All @@ -54,11 +54,22 @@ jobs:
mkdir -p artifacts
filename=env_py${{ matrix.python-version }}_${{ matrix.os }}.yml
conda env export --no-builds | grep -v "prefix" > artifacts/$filename
- name: Install package and test
- name: Install package and dependencies
shell: bash -l {0}
run: |
pip install -e .[testing]
- name: Run unit tests
shell: bash -l {0}
run: |
pytest --cache-clear
- name: Create wheel and dist package
shell: bash -l {0}
run: |
pip install setuptools_scm twine wheel
python setup.py sdist --dist-dir artifacts/dist
python setup.py bdist_wheel --dist-dir artifacts/dist
ls artifacts/dist
twine check artifacts/dist/*
- name: Upload Coverage
shell: bash -l {0}
run: |
Expand All @@ -67,27 +78,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.python-version }}
COVERALLS_PARALLEL: true
- name: Create wheel and dist package
shell: bash -l {0}
run: |
git status
pip install setuptools_scm twine
if [ ${{ matrix.os }} == "windows-latest" ]
then
# build whls on windows
pip install wheel
python setup.py bdist_wheel --dist-dir artifacts/dist
else
# build dist on linux
python setup.py sdist --dist-dir artifacts/dist
fi
ls artifacts/dist
twine check artifacts/dist/*

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Artifacts-${{ matrix.python-version }}-${{ matrix.os }}
path: artifacts/*

coveralls:
name: Submit Coveralls 👚
needs: build
Expand All @@ -99,6 +96,7 @@ jobs:
pip3 install --upgrade coveralls && coveralls --service=github --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish:
name: Upload to PyPI
if: |
Expand Down Expand Up @@ -127,4 +125,4 @@ jobs:
verify_metadata: true
packages_dir: Artifacts/dist/
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }} # this needs to be uploaded to github actions secrets
password: ${{ secrets.PYPI_API_TOKEN }} # this needs to be uploaded to github actions secrets
41 changes: 21 additions & 20 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
pytesmo - a Python Toolbox for the Evaluation of Soil Moisture Observations
***************************************************************************

.. image:: https://github.com/TUW-GEO/pytesmo/workflows/Automated%20Tests/badge.svg?branch=master
|ci| |cov| |pip| |doc|

.. |ci| image:: https://github.com/TUW-GEO/pytesmo/actions/workflows/ci.yml/badge.svg?branch=master
:target: https://github.com/TUW-GEO/pytesmo/actions

.. image:: https://coveralls.io/repos/TUW-GEO/pytesmo/badge.png?branch=master
.. |cov| image:: https://coveralls.io/repos/TUW-GEO/pytesmo/badge.png?branch=master
:target: https://coveralls.io/r/TUW-GEO/pytesmo?branch=master

.. image:: https://badge.fury.io/py/pytesmo.svg
.. |pip| image:: https://badge.fury.io/py/pytesmo.svg
:target: https://badge.fury.io/py/pytesmo

.. image:: https://readthedocs.org/projects/pytesmo/badge/?version=latest
:target: https://pytesmo.readthedocs.io/en/latest/?badge=latest
.. |doc| image:: https://readthedocs.org/projects/pytesmo/badge/?version=latest
:target: https://pytesmo.readthedocs.io/en/latest/

pytesmo, the Python Toolbox for the Evaluation of Soil Moisture Observations, is
a package/python toolbox which aims to provide a library that can be used for
Expand Down Expand Up @@ -45,35 +47,34 @@ If you want to contribute, take a look at the `developers guide
Installation
============

This package should be installable through `pip
This package can be installed through `pip
<https://pip.pypa.io/en/latest/installing.html>`__ which downloads the package
from the `python package repository Pypi <https://pypi.python.org/>`__.
However, pytesmo also needs some packages that depend on C or Fortran libraries (like ``netCDF4``).
They should be installed first with conda or mamba. We recommend installing `Mambaforge <https://github.com/conda-forge/miniforge#mambaforge>`__.
Then the following command should install all dependencies:

.. code-block:: bash
mamba install -c conda-forge 'numpy<2.0.0' scipy pandas netCDF4 cython pyresample
Afterwards ``pytesmo`` can be installed via pip.

.. code-block:: bash
pip install pytesmo
Note that ``pytesmo>=0.17`` will only work with ``numpy>=2.0`` and ``python>=3.9``.
If you still require a version compatible with numpy v1, install ``pytesmo<0.17``.

Compiled C extensions are available as wheels for Windows and Linux for
python 3.9 to 3.12.

As an alternative (e.g. if you want to contribute to the package), you can
clone the Github repository and install from source:
For other operating systems and/or python versions, it might be necessary
to compile the binaries yourself. This should
happen automatically, if you have a C compiler installed (e.g.
`GCC <https://gcc.gnu.org/>`_ ).

.. code::
git clone https://github.com/TUW-GEO/pytesmo.git --recursive
cd pytesmo
mamba create -n pytesmo python=3.10 # or any supported python version
mamba create -n pytesmo python=3.12 # or any supported python version
conda activate pytesmo
mamba env update -f environment.yml -n pytesmo
pip install -e .
pip install -e .[testing] # install source package
python setup.py build_ext --inplace --cythonize # optional compile cython C extensions
pytest # Run tests to check if everything works
Supported Products
==================
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/validation_framework.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"execution_count": null,
"metadata": {
"is_executing": true
},
"outputs": [],
"source": [
"import os\n",
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ channels:
- conda-forge
- defaults
dependencies:
- numpy<2.0.0
- numpy>=2.0.0
- numba
- scipy>=0.12
- pandas>=0.23.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["Cython >= 0.29.23", "setuptools>=46.1.0", "wheel", "setuptools_scm[toml]>=5", "oldest-supported-numpy"]
requires = ["Cython >= 0.29.23", "setuptools>=46.1.0", "wheel", "setuptools_scm[toml]>=5", "numpy>=2,<3"]
build-backend = "setuptools.build_meta"
[tool]
[tool.setuptools_scm]
Expand Down
20 changes: 12 additions & 8 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,19 @@ package_dir =
# Add here dependencies of your project (semicolon/line-separated), e.g.
install_requires =
importlib-metadata; python_version<"3.8"
numpy>=1.7.0,<2.0.0
numpy>=2.0
numba
scipy>=0.12
pandas>=0.23.0
matplotlib>=1.2.0
netCDF4>=1.0.1,!=1.6.2
pygeogrids
pygeobase>=0.6.0
pynetcf>=0.4.0
configparser
pykdtree
repurpose>=0.7.1
repurpose>=0.13.1
cadati>=0.0.2
Cython>=0.29.21
numba
scikit-learn
# The usage of test_requires is discouraged, see `Dependency Management` docs
# tests_require = pytest; pytest-cov
Expand All @@ -62,13 +61,18 @@ exclude =
# PDF = ReportLab; RXP
# Add here test requirements (semicolon/line-separated)
testing =
ascat==2.4.3
ismn==1.5.1
nbconvert
ipykernel
sphinx_rtd_theme
matplotlib
pytest
pytest-cov
pytest-mpl
nbconvert
ipykernel
ascat>=2.0
ismn==1.3.4
pre-commit
flake8
yapf

[options.entry_points]
# Add here console scripts like:
Expand Down
Loading

0 comments on commit 25e8dfa

Please sign in to comment.