Skip to content

Commit f90a87d

Browse files
committed
Document requirement_cycles in rtd
1 parent 8a4e2fc commit f90a87d

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

docs/sphinx/pypi-dependencies.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,70 @@ Any 'extras' specified in the requirements lock file will be automatically added
130130
as transitive dependencies of the package. In the example above, you'd just put
131131
`requirement("useful_dep")`.
132132

133+
### Packaging cycles
134+
135+
Sometimes PyPi packages contain dependency cycles -- for instance `sphinx`
136+
depends on `sphinxcontrib-serializinghtml`. When using them as `requirement()`s,
137+
ala
138+
139+
```
140+
py_binary(
141+
name = "doctool",
142+
...
143+
deps = [
144+
requirement("sphinx"),
145+
]
146+
)
147+
```
148+
149+
Bazel will protest because it doesn't support cycles in the build graph --
150+
151+
```
152+
ERROR: .../external/pypi_sphinxcontrib_serializinghtml/BUILD.bazel:44:6: in alias rule @pypi_sphinxcontrib_serializinghtml//:pkg: cycle in dependency graph:
153+
//:doctool (...)
154+
@pypi//sphinxcontrib_serializinghtml:pkg (...)
155+
.-> @pypi_sphinxcontrib_serializinghtml//:pkg (...)
156+
| @pypi_sphinxcontrib_serializinghtml//:_pkg (...)
157+
| @pypi_sphinx//:pkg (...)
158+
| @pypi_sphinx//:_pkg (...)
159+
`-- @pypi_sphinxcontrib_serializinghtml//:pkg (...)
160+
```
161+
162+
The `requirement_cycles` argument allows you to work around these issues by
163+
specifying groups of packages which form cycles. `pip_parse` will transparently
164+
fix the cycles for you and provide the cyclic dependencies simultaneously.
165+
166+
```
167+
pip_parse(
168+
...
169+
requirement_cycles = {
170+
"sphinx": [
171+
"sphinx",
172+
"sphinxcontrib-serializinghtml",
173+
]
174+
},
175+
)
176+
```
177+
178+
`pip_parse` supports fixing multiple cycles simultaneously, however cycles must
179+
be distinct. `apache-airflow` for instance has dependency cycles with a number
180+
of its optional dependencies, which means those optional dependencies must all
181+
be a part of the `airflow` cycle. For instance --
182+
183+
```
184+
pip_parse(
185+
...
186+
requirement_cycles = {
187+
"airflow": [
188+
"apache-airflow",
189+
"apache-airflow-providers-common-sql",
190+
"apache-airflow-providers-postgres",
191+
"apache-airflow-providers-sqlite",
192+
]
193+
}
194+
)
195+
```
196+
133197
## Consuming Wheel Dists Directly
134198

135199
If you need to depend on the wheel dists themselves, for instance, to pass them

0 commit comments

Comments
 (0)