Commit fda67376 by Mathieu Kniewallner Committed by GitHub

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
parent 71a1b7a6
...@@ -288,17 +288,28 @@ poetry will choose a suitable one based on the available package versions. ...@@ -288,17 +288,28 @@ poetry will choose a suitable one based on the available package versions.
poetry add requests pendulum poetry add requests pendulum
``` ```
You also can specify a constraint when adding a package, like so: You can also specify a constraint when adding a package:
```bash ```bash
# Allow >=2.0.5, <3.0.0 versions
poetry add pendulum@^2.0.5 poetry add pendulum@^2.0.5
# Allow >=2.0.5, <2.1.0 versions
poetry add pendulum@~2.0.5
# Allow >=2.0.5 versions, without upper bound
poetry add "pendulum>=2.0.5" poetry add "pendulum>=2.0.5"
# Allow only 2.0.5 version
poetry add pendulum==2.0.5
``` ```
If you try to add a package that is already present, you will get an error. If you try to add a package that is already present, you will get an error.
However, if you specify a constraint, like above, the dependency will be updated However, if you specify a constraint, like above, the dependency will be updated
by using the specified constraint. If you want to get the latest version of an already by using the specified constraint.
present dependency you can use the special `latest` constraint:
If you want to get the latest version of an already
present dependency, you can use the special `latest` constraint:
```bash ```bash
poetry add pendulum@latest poetry add pendulum@latest
...@@ -319,8 +330,7 @@ or use ssh instead of https: ...@@ -319,8 +330,7 @@ or use ssh instead of https:
```bash ```bash
poetry add git+ssh://git@github.com/sdispater/pendulum.git poetry add git+ssh://git@github.com/sdispater/pendulum.git
or alternatively: # or alternatively:
poetry add git+ssh://git@github.com:sdispater/pendulum.git poetry add git+ssh://git@github.com:sdispater/pendulum.git
``` ```
...@@ -331,8 +341,7 @@ you can specify it when using `add`: ...@@ -331,8 +341,7 @@ you can specify it when using `add`:
poetry add git+https://github.com/sdispater/pendulum.git#develop poetry add git+https://github.com/sdispater/pendulum.git#develop
poetry add git+https://github.com/sdispater/pendulum.git#2.0.5 poetry add git+https://github.com/sdispater/pendulum.git#2.0.5
or using SSH instead: # or using SSH instead:
poetry add git+ssh://github.com/sdispater/pendulum.git#develop poetry add git+ssh://github.com/sdispater/pendulum.git#develop
poetry add git+ssh://github.com/sdispater/pendulum.git#2.0.5 poetry add git+ssh://github.com/sdispater/pendulum.git#2.0.5
``` ```
......
...@@ -71,15 +71,18 @@ Here are some examples of inequality requirements: ...@@ -71,15 +71,18 @@ Here are some examples of inequality requirements:
!= 1.2.3 != 1.2.3
``` ```
#### Multiple requirements
Multiple version requirements can also be separated with a comma, e.g. `>= 1.2, < 1.5`.
### Exact requirements ### Exact requirements
You can specify the exact version of a package. You can specify the exact version of a package.
This will tell Poetry to install this version and this version only.
If other dependencies require a different version, the solver will ultimately fail and abort any install or update procedures.
#### Multiple requirements `==1.2.3` is an example of an exact version specification.
Multiple version requirements can also be separated with a comma, e.g. `>= 1.2, < 1.5`. This will tell Poetry to install this version and this version only.
If other dependencies require a different version, the solver will ultimately fail and abort any install or update procedures.
## `git` dependencies ## `git` dependencies
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment