Skip to content

Add uv config - #1286

Open
peanutfun wants to merge 103 commits into
developfrom
add-uv-config
Open

peanutfun wants to merge 103 commits into
developfrom
add-uv-config

Conversation

@peanutfun

@peanutfun peanutfun commented Apr 30, 2026 •

Copy link
Copy Markdown
Member

This PR makes CLIMADA installable with plain pip, and thus also enables the use of uv.

A sister branch is created in Petals to update the CI configuration there (see add-uv-config). For the moment, Petals cannot be made pip-installable simultaneously, as several dependencies block that.

Changes proposed in this PR:

  • Remove GDAL as direct dependency. GDAL itself cannot be installed with pip.
    • Instead of GDAL, use rasterio to read a GeoTIFF file. Update code and tests accordingly. (Tests were buggy, code is not used in any recent module 🙄)
  • Consolidate requirement specs.
    • Define all requirements in pyproject.toml
    • Use dependency groups instead of extra requirements (these dependencies are not actually requirements)
    • Use my program pyproject-to-conda-env to translate pyproject.toml to Conda environment specs automatically (with pre-commit).
  • Add installation instructions for uv and pip
    • Organize instructions for different package managers in tabs for better overview.
  • Add guide for dependency management with pip
  • Update CI testing pipeline:
    • Run integration tests in the GitHub pipeline. Download and cache testing data from Zenodo: https://doi.org/10.5281/zenodo.20592941
    • Use pip to install requirements for unit tests
    • Use uv to install requirements for integration tests
    • Add a separate unit test pipeline still running Mamba (to ensure environment management works there)
  • Update readthedocs.org config to use uv for environment management
    • Update doc/README.md to reflect these changes

This PR fixes #1100

PR Author Checklist

PR Reviewer Checklist

Comment thread Makefile Resolved

@emanuel-schmid emanuel-schmid left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great job!

Found one issue: eccodeslib doesn't exist for windows. So I'd follow the suggestion from the linked astral-sh/uv/issue. It worked for me on Linux and Windows.

Comment thread pyproject.toml Resolved
Comment thread pyproject.toml Resolved
peanutfun and others added 3 commits November 19, 2026 14:01
Apply batched suggestions from code review

Co-authored-by: Emanuel Schmid <51439563+emanuel-schmid@users.noreply.github.com>
@peanutfun

Copy link
Copy Markdown
Member Author

@emanuel-schmid Thanks for checking this out. The [[dependency-metadata]] is a uv-feature. I now added a general, pip-compatible flag. Can you give it another try on Windows (with pip)?

@peanutfun

Copy link
Copy Markdown
Member Author

@emanuel-schmid I resolved the eccodeslib issue, I think. Can you give it another try?

@chahank @spjuhel I would welcome your comments on the updated guidelines, see

@peanutfun
peanutfun marked this pull request as ready for review December 1, 2026 11:12
@peanutfun
peanutfun requested a review from chahank as a code owner December 1, 2026 11:12
@spjuhel

spjuhel commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Many very neat improvements, this is amazing really!

Some curiosity on the CI/CD script:

  • Why use pip for unittest requirements and uv for integration requirements?
  • Why the check for cfgrid / xarray ? Maybe worth documenting with a comment?

About the doc:

I find it overall clear and well-structured (see minor comments below). However, I've come to realise my personal view of what are "clear install instructions" is not very representative. I think we should ask @ValentinGebhart maybe?

Minor comments you can choose to disregard:

I'm personally weirded out by "Mamba/Conda/Pip/Pixi" instead of "mamba/conda/pip/pixi" in the documentation but that's very personal no strong feelings here.

I'd vote for removing the Spyder part altogether at this point. (User that still use another IDE that VSCode probably know what they are doing anyway. (Probably the same for the "Apps for Working with CLIMADA" ?)

Also thinking How to update should be outside of the FAQs and maybe included in the simple/advanced instructions directly?

I think the Conda as Alternative to Mamba part is outdated and irrelevant now.

We commit ``uv.lock`` to the git source tree.
The lockfile represents the exact environment created when installing CLIMADA from source (with uv).
Adding or updating dependencies of CLIMADA will change the lockfile, as will upgrading packages within the environment.
These changes should only be committed if this seems appropriate, either because dependency defintions changed or a default package should or must be upgraded.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
These changes should only be committed if this seems appropriate, either because dependency defintions changed or a default package should or must be upgraded.
These changes should only be committed if this seems appropriate, either because dependency definitions changed or a default package should or must be upgraded.

@peanutfun

peanutfun commented Dec 3, 2026 •

Copy link
Copy Markdown
Member Author

ToDo:

  • Remove pip from install instructions (manual venv handling is too cumbersome)
  • Lowercase tool names
  • Add TLDR to install instructions
  • Remove outdated FAQs
  • Link to update climada from simple/advanced instructions
  • Remove cfgrib check
  • Use pip for integration tests

@peanutfun

Copy link
Copy Markdown
Member Author

Some curiosity on the CI/CD script:
Why use pip for unittest requirements and uv for integration requirements?

  1. uv makes it simple to install zenodo_get BUT we could also just install it with pip
  2. I wanted to use the pinned dependencies for the integration tests BUT now I think it makes more sense to use the latest versions, too.
  3. One is able to see the workflow with uv BUT this might be too confusing when compared to the unit test pipeline.

So I guess I'll use pip for the integration tests, too.

Why the check for cfgrid / xarray ? Maybe worth documenting with a comment?

uv and pip behaved differently when installing eccodes, leaving cfgrib unusable. I added a diagnostic to debug that. I'll remove it.

@peanutfun

Copy link
Copy Markdown
Member Author

@spjuhel One strong argument PRO uv in both unit tests and integration tests: Installing dependencies takes ~6s instead of ~60s

@peanutfun

peanutfun commented Dec 3, 2026 •

Copy link
Copy Markdown
Member Author

@emanuel-schmid Did your merge from develop enable testing on Python 3.14? This fails apparently because pip wheels for fiona might still be unavailable at the moment: Toblerity/Fiona#1530 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants