Skip to content

Commit

Permalink
馃摑 uv docs
Browse files Browse the repository at this point in the history
  • Loading branch information
juftin committed Feb 22, 2024
1 parent 9721b45 commit 7ac1068
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</div>

<p align="center">
<a href="https://github.com/pypa/hatch">hatch</a> plugin to use <a href="https://github.com/jazzband/pip-tools">pip-compile</a> to manage project dependencies and lockfiles.
<a href="https://github.com/pypa/hatch">hatch</a> plugin to use <a href="https://github.com/jazzband/pip-tools">pip-compile</a> (or <a href="https://github.com/astral-sh/uv">uv</a>) to manage project dependencies and lockfiles.
</p>

<p align="center">
Expand All @@ -19,6 +19,7 @@
<a href="https://codecov.io/gh/juftin/hatch-pip-compile"><img src="https://codecov.io/gh/juftin/hatch-pip-compile/graph/badge.svg?token=PCGB5QIC8M"/></a>
<a href="https://github.com/pypa/hatch"><img src="https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg" alt="Hatch project"></a>
<a href="https://github.com/jazzband/pip-tools"><img src="https://raw.githubusercontent.com/jazzband/website/main/jazzband/static/img/badge.svg" alt="Pip Tools project"></a>
<a href="https://github.com/astral-sh/uv"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" alt="uv"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a>
<a href="https://github.com/pre-commit/pre-commit"><img src="https://img.shields.io/badge/pre--commit-enabled-lightgreen?logo=pre-commit" alt="pre-commit"></a>
<a href="https://github.com/semantic-release/semantic-release"><img src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg" alt="semantic-release"></a>
Expand Down Expand Up @@ -88,6 +89,7 @@ Set your environment type to `pip-compile` to use this plugin for the respective
- [pip-compile-constraint](docs/examples.md#pip-compile-constraint) - syncing dependency versions across environments
- [Upgrading Dependencies](docs/examples.md#upgrading-dependencies) - how to upgrade dependencies
- [Using Hashes](docs/examples.md#pip-compile-hashes) - how to include hashes in your lockfile
- [Using uv instead of pip-compile](docs/examples.md#pip-compile-resolver) - how to use `uv` instead of `pip-compile`

### Configuration Options

Expand All @@ -110,15 +112,16 @@ pip-compile-hashes = true
| [lock-filename](docs/examples.md#lock-filename) | `str` | The filename of the ultimate lockfile. `default` env is `requirements.txt`, non-default is `requirements/requirements-{env_name}.txt` |
| [pip-compile-constraint](docs/examples.md#pip-compile-constraint) | `str` | An environment to use as a constraint file, ensuring that all shared dependencies are pinned to the same versions. |
| [pip-compile-hashes](docs/examples.md#pip-compile-hashes) | `bool` | Whether to generate hashes in the lockfile. Defaults to `false`. |
| [pip-compile-resolver](docs/examples.md#pip-compile-resolver) | `str` | Whether to use `pip-compile` or `uv` to resolve dependencies into the project. Defaults to `pip-compile` |
| [pip-compile-args](docs/examples.md#pip-compile-args) | `list[str]` | Additional command-line arguments to pass to `pip-compile-resolver` |
| [pip-compile-verbose](docs/examples.md#pip-compile-verbose) | `bool` | Set to `true` to run `pip-compile` in verbose mode instead of quiet mode, set to `false` to silence warnings |
| [pip-compile-args](docs/examples.md#pip-compile-args) | `list[str]` | Additional command-line arguments to pass to `pip-compile` |

#### Installing Lockfiles

| name | type | description |
| --------------------------------------------------------------------- | ----------- | ---------------------------------------------------------------------------------------------- |
| [pip-compile-installer](docs/examples.md#pip-compile-installer) | `str` | Whether to use `pip` or `pip-sync` to install dependencies into the project. Defaults to `pip` |
| [pip-compile-install-args](docs/examples.md#pip-compile-install-args) | `list[str]` | Additional command-line arguments to pass to `pip-compile-installer` |
| name | type | description |
| --------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------- |
| [pip-compile-installer](docs/examples.md#pip-compile-installer) | `str` | Whether to use `pip`, `pip-sync`, or `uv` to install dependencies into the project. Defaults to `pip` |
| [pip-compile-install-args](docs/examples.md#pip-compile-install-args) | `list[str]` | Additional command-line arguments to pass to `pip-compile-installer` |

<!--skip-->

Expand Down
50 changes: 41 additions & 9 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,38 @@ Whether to generate hashes in the lockfile. Defaults to `false`.
pip-compile-hashes = true
```

## pip-compile-resolver

Which resolver to use to generate the lockfile. Defaults to `pip-compile`.

[uv] is a drop in replacement for `pip-compile` with a much faster resolver written in rust.
If you'd like to use `uv` instead of `pip-compile` you can set the `pip-compile-resolver` option.

> NOTE: **pip-compile-installer**
>
> [uv] can also be used as the default installer instead of `pip`. See
> the [pip-compile-installer](#pip-compile-installer) option for more
> information.
- **_pyproject.toml_**

```toml
[tool.hatch.envs.<envName>]
type = "pip-compile"
pip-compile-resolver = "uv"
```

- **_hatch.toml_**

```toml
[envs.<envName>]
type = "pip-compile"
pip-compile-resolver = "uv"
```

## pip-compile-args

Extra arguments to pass to `pip-compile`. Custom PyPI indexes can be specified here.
Extra arguments to pass to `pip-compile-resolver`. Custom PyPI indexes can be specified here.

- **_pyproject.toml_**

Expand Down Expand Up @@ -161,7 +190,8 @@ Extra arguments to pass to `pip-compile`. Custom PyPI indexes can be specified h

Set to `true` to run `pip-compile` in verbose mode instead of quiet mode.

Optionally, if you would like to silence any warnings set the `pip-compile-verbose` option to `false`.
Optionally, if you would like to silence any warnings set the `pip-compile-verbose` option
to `false`.

- **_pyproject.toml_**

Expand All @@ -181,15 +211,16 @@ Optionally, if you would like to silence any warnings set the `pip-compile-verbo

## pip-compile-installer

Whether to use [pip] or [pip-sync] to install dependencies into the project. Defaults to `pip`.
When you choose the `pip` option the plugin will run `pip install -r {lockfile}` under the hood
to install the dependencies. When you choose the `pip-sync` option `pip-sync {lockfile}` is invoked
by the plugin.
Whether to use [pip], [pip-sync], or [uv] to install dependencies into the project. Defaults
to `pip`. When you choose the `pip` option the plugin will run `pip install -r {lockfile}`
under the hood to install the dependencies. When you choose the `pip-sync` option
`pip-sync {lockfile}` is invoked by the plugin. [uv] is a drop in replacement for
`pip`, it has the same behavior as `pip` installer, `uv pip install -r {lockfile}`.

The key difference between these options is that `pip-sync` will uninstall any packages that are
not in the lockfile and remove them from your environment. `pip-sync` is useful if you want to ensure
that your environment is exactly the same as the lockfile. If the environment should be used
across different Python versions and platforms `pip` is the safer option to use.
not in the lockfile and remove them from your environment. `pip-sync` is useful if you want to
ensure that your environment is exactly the same as the lockfile. If the environment should
be used across different Python versions and platforms `pip` is the safer option to use.

- **_pyproject.toml_**

Expand Down Expand Up @@ -237,3 +268,4 @@ installer but want to pass the `--no-deps` flag to `pip install` you can do so w
[pip-sync]: https://github.com/jazzband/pip-tools
[pip]: https://pip.pypa.io
[inheritance]: hhttps://hatch.pypa.io/latest/config/environment/overview/#inheritance
[uv]: https://github.com/astral-sh/uv
1 change: 0 additions & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ repo_name: hatch-pip-compile
edit_uri: blob/main/docs/
site_author: juftin
remote_branch: gh-pages
copyright: Copyright 漏 2023 Justin Flannery
extra:
generator: false
exclude_docs: |
Expand Down

0 comments on commit 7ac1068

Please sign in to comment.