Metadata-Version: 2.4
Name: pymetkit
Version: 1.20.2.27
Summary: Python interface to metkit
Author-email: European Centre for Medium-Range Weather Forecasts (ECMWF) <software.support@ecmwf.int>
License-Expression: Apache-2.0
Project-URL: Documentation, https://github.com/ecmwf/metkit
Project-URL: Homepage, https://github.com/ecmwf/metkit
Project-URL: Issues, https://github.com/ecmwf/metkit/issues
Project-URL: Repository, https://github.com/ecmwf/metkit
Keywords: python,metkit,mars,tools
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: findlibs>=0.1.2
Requires-Dist: metkitlib==1.20.2.27
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-flakes; extra == "test"
Requires-Dist: Sybil[pytest]; extra == "test"
Provides-Extra: docs
Requires-Dist: Sphinx; extra == "docs"
Requires-Dist: breathe; extra == "docs"
Requires-Dist: sphinx-book-theme; extra == "docs"
Requires-Dist: requests; extra == "docs"
Requires-Dist: sphinxcontrib-mermaid; extra == "docs"
Requires-Dist: autoapi; extra == "docs"
Requires-Dist: sphinx-autoapi; extra == "docs"
Provides-Extra: dev
Requires-Dist: isort; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: license-expression
Dynamic: requires-dist
Dynamic: requires-python

# pymetkit

`pymetkit` is a Python interface to [metkit](https://github.com/ecmwf/metkit), ECMWF's
meteorological toolkit. It exposes the MARS request model in a Pythonic way, built on a
[pybind11](https://github.com/pybind/pybind11) extension module (`pymetkit_bindings`) that binds the
metkit C++ library directly.

The native `libmetkit` shared library and its dependencies are located at runtime via
[findlibs](https://github.com/ecmwf/findlibs).

## Architecture

- `pymetkit_bindings` — compiled pybind11 module binding `metkit::mars::MarsRequest` and
  `metkit::mars::MarsExpansion`.
- `pymetkit._internal` — loads the native library via `findlibs`, initialises the bindings, and
  re-exports the raw symbols.
- `pymetkit` — the Pythonic layer: `MarsRequest` (a verb plus a `MarsSelection`),
  `MarsSelection` (a type alias for the user-facing key-value mapping),
  `UserInputMapper` (normalises `MarsSelection` values to and from the internal
  `dict[str, list[str]]` representation), and `parse_mars_request`.

## Usage

```python
from pymetkit import MarsRequest, parse_mars_request

# Build a request from a verb and a selection
request = MarsRequest(
    "retrieve",
    {
        "class": "od",
        "domain": "g",
        "date": "-1",
        "expver": "0001",
        "step": range(0, 13, 6),
    },
)

# Expand against the MARS language definition
expanded = request.expand()
print(expanded.verb(), dict(expanded))

# Parse requests from a string or a file
requests = parse_mars_request("retrieve,class=od,date=-1,param=129,step=12")
```

## Command line

```bash
python -m pymetkit --print-home        # metkit library home
python -m pymetkit --print-home-deps   # all dependency homes and versions
```
