Metadata-Version: 2.5
Name: nab-project
Version: 0.0.31
Summary: Python project resolution, lockfiles and downloads for nab
Project-URL: Homepage, https://github.com/notatallshaw/nab
Project-URL: Documentation, https://nab.readthedocs.io/
Project-URL: Issues, https://github.com/notatallshaw/nab/issues
Project-URL: Source, https://github.com/notatallshaw/nab
Project-URL: Changelog, https://github.com/notatallshaw/nab/releases
Author-email: Damian Shaw <damian.peter.shaw@gmail.com>
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
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: Programming Language :: Python :: 3.15
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: build>=1.2
Requires-Dist: installer>=1.0
Requires-Dist: nab-index==0.0.31
Requires-Dist: nab-markersets==0.0.31
Requires-Dist: nab-provider==0.0.31
Requires-Dist: nab-resolver==0.0.31
Requires-Dist: packaging>=26.4
Requires-Dist: pyproject-hooks>=1.2
Requires-Dist: tomli>=2.2
Requires-Dist: typing-extensions>=4.6
Description-Content-Type: text/markdown

# nab-project

Use `nab-project` to resolve project dependencies, build wheels from source and write lockfiles. It
fetches distributions through [`nab-index`](https://pypi.org/project/nab-index/) and applies
packaging rules through [`nab-provider`](https://pypi.org/project/nab-provider/). The API is
experimental. Pin an exact version when embedding it.

## Resolve for the current interpreter

```python
from pathlib import Path

from nab_index.urllib3_async_transport import Urllib3AsyncTransport
from nab_project.inputs import ResolveInputs
from nab_project.resolve import resolve_for_targets
from nab_provider.target import ResolveTarget


def project_versions(path: Path, inputs: ResolveInputs) -> dict[str, str]:
    result = resolve_for_targets(
        path,
        Urllib3AsyncTransport(),
        targets=[ResolveTarget.for_host()],
        inputs=inputs,
    )
    result.raise_for_failure()
    return {
        name: str(version) for name, version in result.target_results[0].pins.items()
    }
```

Call `project_versions(Path("pyproject.toml"), ResolveInputs())` to use PyPI. To supply your own
indexes, pass `ResolveInputs(indexes=...)`.

A failed target also produces a result, so call `raise_for_failure()` before using its pins.

To read Nab's configuration files, also install the matching `nab` distribution. Import
`read_pyproject_config` and `plan_targets` from `nab.config.model`, then call
`config = read_pyproject_config(path)`. Pass `inputs=config.resolve_inputs()` and
`targets=plan_targets(config)` to `resolve_for_targets`.

For the requirements behind the selected versions, pass `include_dependency_requirements=True`. Each
successful target result then exposes them through `dependency_requirements()`.
