You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor/docs: improve compile_pip_requirements error message and docs (#2792)
Resolution failure is the most common error from pip-compile, so we
should make sure the error message is as clean as it can be. Previously,
the output was cluttered with the exception traceback, which makes the
actual error hard to see (several nested traceback).
The new output shortens it with a nicer message:
```
Checking _main/requirements_lock.txt
ERROR: Cannot install requests<2.24 and requests~=2.25.1 because these package versions have conflicting dependencies.
ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
```
Fixes#2763
---------
Co-authored-by: Richard Levasseur <[email protected]>
2.[Installing third party packages](#installing-third-party-packages)
10
+
3.[Using third party packages as dependencies](#using-third-party-packages)
11
+
12
+
{#generating-requirements-file}
13
+
## Generating requirements file
14
+
15
+
Generally, when working on a Python project, you'll have some dependencies that themselves have other dependencies. You might also specify dependency bounds instead of specific versions. So you'll need to generate a full list of all transitive dependencies and pinned versions for every dependency.
16
+
17
+
Typically, you'd have your dependencies specified in `pyproject.toml` or `requirements.in` and generate the full pinned list of dependencies in `requirements_lock.txt`, which you can manage with the `compile_pip_requirements` Bazel rule:
-`bazel run [name].update` will regenerate the `requirements_txt` file
31
+
-`bazel test [name]_test` will test that the `requirements_txt` file is up to date
32
+
33
+
For more documentation, see the API docs under {obj}`@rules_python//python:pip.bzl`.
34
+
35
+
Once you generate this fully specified list of requirements, you can install the requirements with the instructions in [Installing third party packages](#installing-third-party-packages).
36
+
37
+
:::{warning}
38
+
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.
39
+
40
+
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)).
41
+
:::
10
42
11
43
{#installing-third-party-packages}
12
44
## Installing third party packages
@@ -27,8 +59,7 @@ pip.parse(
27
59
)
28
60
use_repo(pip, "my_deps")
29
61
```
30
-
For more documentation, including how the rules can update/create a requirements
31
-
file, see the bzlmod examples under the {gh-path}`examples` folder or the documentation
62
+
For more documentation, see the bzlmod examples under the {gh-path}`examples` folder or the documentation
32
63
for the {obj}`@rules_python//python/extensions:pip.bzl` extension.
0 commit comments