Skip to content

Commit 200baa7

Browse files
FBruzzesiEdAbati
andauthored
docs: Add warning when adding Narwhals with extras (#3658)
--------- Co-authored-by: Edoardo Abati <29585319+EdAbati@users.noreply.github.com>
1 parent 2fc2dda commit 200baa7

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

docs/installation.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,42 @@ Specify one or more extras in square brackets, for example:
6969
poetry add "narwhals[polars,pyarrow]"
7070
```
7171

72+
!!! warning "Library authors: prefer keeping backends out of your direct dependencies"
73+
74+
`uv add "narwhals[polars,pyarrow]"` adds the extras to `[project.dependencies]`.
75+
76+
If you publish your project, **every consumer is then forced to install polars and
77+
pyarrow**, which defeats Narwhals' "support all, depend on none" design.
78+
79+
If you're building a library (rather than an application), keep `narwhals` as your
80+
runtime dependency and pin the backends only for development:
81+
82+
=== "uv"
83+
84+
```terminal
85+
uv add narwhals
86+
uv add --group dev "narwhals[polars,pyarrow]"
87+
```
88+
89+
=== "Poetry"
90+
91+
```terminal
92+
poetry add narwhals
93+
poetry add --group dev "narwhals[polars,pyarrow]"
94+
```
95+
96+
Dependency groups are not shipped in your distribution metadata, so consumers
97+
receive only `narwhals` and bring their own backend.
98+
99+
Alternatively, re-expose the backends as your library's **own optional extras**, so
100+
consumers opt in explicitly (e.g. `pip install your-library[polars]`):
101+
102+
```toml
103+
[project.optional-dependencies]
104+
polars = ["narwhals[polars]"]
105+
pyarrow = ["narwhals[pyarrow]"]
106+
```
107+
72108
### Verifying the installation
73109

74110
To verify the installation, start the Python REPL and execute:

0 commit comments

Comments
 (0)