Skip to content

Commit fda6737

Browse files
authored
Better document exact requirement specification (#5874)
* doc(*): better document exact requirements * doc: move `Multiple requirements` under `Inequality requirements` * doc: detail a bit more `add` possibilities
1 parent 71a1b7a commit fda6737

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

docs/cli.md

+16-7
Original file line numberDiff line numberDiff line change
@@ -288,17 +288,28 @@ poetry will choose a suitable one based on the available package versions.
288288
poetry add requests pendulum
289289
```
290290

291-
You also can specify a constraint when adding a package, like so:
291+
You can also specify a constraint when adding a package:
292292

293293
```bash
294+
# Allow >=2.0.5, <3.0.0 versions
294295
poetry add pendulum@^2.0.5
296+
297+
# Allow >=2.0.5, <2.1.0 versions
298+
poetry add pendulum@~2.0.5
299+
300+
# Allow >=2.0.5 versions, without upper bound
295301
poetry add "pendulum>=2.0.5"
302+
303+
# Allow only 2.0.5 version
304+
poetry add pendulum==2.0.5
296305
```
297306

298307
If you try to add a package that is already present, you will get an error.
299308
However, if you specify a constraint, like above, the dependency will be updated
300-
by using the specified constraint. If you want to get the latest version of an already
301-
present dependency you can use the special `latest` constraint:
309+
by using the specified constraint.
310+
311+
If you want to get the latest version of an already
312+
present dependency, you can use the special `latest` constraint:
302313

303314
```bash
304315
poetry add pendulum@latest
@@ -319,8 +330,7 @@ or use ssh instead of https:
319330
```bash
320331
poetry add git+ssh://[email protected]/sdispater/pendulum.git
321332

322-
or alternatively:
323-
333+
# or alternatively:
324334
poetry add git+ssh://[email protected]:sdispater/pendulum.git
325335
```
326336

@@ -331,8 +341,7 @@ you can specify it when using `add`:
331341
poetry add git+https://github.com/sdispater/pendulum.git#develop
332342
poetry add git+https://github.com/sdispater/pendulum.git#2.0.5
333343

334-
or using SSH instead:
335-
344+
# or using SSH instead:
336345
poetry add git+ssh://github.com/sdispater/pendulum.git#develop
337346
poetry add git+ssh://github.com/sdispater/pendulum.git#2.0.5
338347
```

docs/dependency-specification.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,18 @@ Here are some examples of inequality requirements:
7171
!= 1.2.3
7272
```
7373

74+
#### Multiple requirements
75+
76+
Multiple version requirements can also be separated with a comma, e.g. `>= 1.2, < 1.5`.
77+
7478
### Exact requirements
7579

7680
You can specify the exact version of a package.
77-
This will tell Poetry to install this version and this version only.
78-
If other dependencies require a different version, the solver will ultimately fail and abort any install or update procedures.
7981

80-
#### Multiple requirements
82+
`==1.2.3` is an example of an exact version specification.
8183

82-
Multiple version requirements can also be separated with a comma, e.g. `>= 1.2, < 1.5`.
84+
This will tell Poetry to install this version and this version only.
85+
If other dependencies require a different version, the solver will ultimately fail and abort any install or update procedures.
8386

8487
## `git` dependencies
8588

0 commit comments

Comments
 (0)