Skip to content

Commit 121c5e3

Browse files
committed
docs: tell how to emulate dependency groups with pip-compile
1 parent c30980a commit 121c5e3

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

docs/pypi/lock.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
:::{note}
77
Currently `rules_python` only supports `requirements.txt` format.
8+
9+
#{gh-issue}`3088` tracks `pylock.toml` support.
810
:::
911

1012
## requirements.txt
@@ -37,11 +39,33 @@ This rule generates two targets:
3739
Once you generate this fully specified list of requirements, you can install the requirements ([bzlmod](./download)/[WORKSPACE](./download-workspace)).
3840

3941
:::{warning}
40-
If you're specifying dependencies in `pyproject.toml`, make sure to include the `[build-system]` configuration, with pinned dependencies. `compile_pip_requirements` will use the build system specified to read your project's metadata, and you might see non-hermetic behavior if you don't pin the build system.
42+
If you're specifying dependencies in `pyproject.toml`, make sure to include the
43+
`[build-system]` configuration, with pinned dependencies.
44+
`compile_pip_requirements` will use the build system specified to read your
45+
project's metadata, and you might see non-hermetic behavior if you don't pin the
46+
build system.
4147

42-
Not specifying `[build-system]` at all will result in using a default `[build-system]` configuration, which uses unpinned versions ([ref](https://peps.python.org/pep-0518/#build-system-table)).
48+
Not specifying `[build-system]` at all will result in using a default
49+
`[build-system]` configuration, which uses unpinned versions
50+
([ref](https://peps.python.org/pep-0518/#build-system-table)).
4351
:::
4452

53+
54+
#### pip compile Dependency groups
55+
56+
pip-compile doesn't yet support pyproject.toml dependency groups. Follow
57+
[pip-tools #2062](https://github.com/jazzband/pip-tools/issues/2062)
58+
to see the status of their support.
59+
60+
In the meantime, support can be emulated by passing multiple files to `srcs`:
61+
62+
```starlark
63+
compile_pip_requirements(
64+
srcs = ["pyproject.toml", "requirements-dev.in"]
65+
...
66+
)
67+
```
68+
4569
### uv pip compile (bzlmod only)
4670

4771
We also have experimental setup for the `uv pip compile` way of generating lock files.

python/private/pypi/pip_compile.bzl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def pip_compile(
4040
tags = None,
4141
constraints = [],
4242
**kwargs):
43-
"""Generates targets for managing pip dependencies with pip-compile.
43+
"""Generates targets for managing pip dependencies with pip-compile (piptools).
4444
4545
By default this rules generates a filegroup named "[name]" which can be included in the data
4646
of some other compile_pip_requirements rule that references these requirements
@@ -65,7 +65,10 @@ def pip_compile(
6565
* a requirements text file, usually named `requirements.in`
6666
* A `.toml` file, where the `project.dependencies` list is used as per
6767
[PEP621](https://peps.python.org/pep-0621/).
68-
extra_args: passed to pip-compile.
68+
extra_args: passed to pip-compile (aka `piptools`). See the
69+
[pip-compile docs](https://pip-tools.readthedocs.io/en/latest/cli/pip-compile)
70+
for args and meaning (passing `-h` and/or `--version` can help
71+
inform what args are available)
6972
extra_deps: extra dependencies passed to pip-compile.
7073
generate_hashes: whether to put hashes in the requirements_txt file.
7174
py_binary: the py_binary rule to be used.

0 commit comments

Comments
 (0)