-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the add and init commands (#1221)
* Add the ability to specify path and git dependencies directly in add * Add the ability to add git and path dependencies via the init command * Automatically select latest prereleases if only prereleases are available * Update documentation for the add command * Add the ability to add complete dependencies in one go
- Loading branch information
Showing
8 changed files
with
891 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,36 +182,67 @@ poetry will choose a suitable one based on the available package versions. | |
poetry add requests pendulum | ||
``` | ||
|
||
You also can specify a constraint when adding a package, like so: | ||
|
||
```bash | ||
poetry add pendulum@^2.0.5 | ||
poetry add "pendulum>=2.0.5" | ||
``` | ||
|
||
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 | ||
by using the specified constraint. If you want to get the latest version of an already | ||
present dependency you can use the special `latest` constraint: | ||
|
||
```bash | ||
poetry add pendulum@latest | ||
``` | ||
|
||
You can also add `git` dependencies: | ||
|
||
```bash | ||
poetry add pendulum --git https://github.com/sdispater/pendulum.git | ||
poetry add git+https://github.com/sdispater/pendulum.git | ||
``` | ||
|
||
If you need to checkout a specific branch, tag or revision, | ||
you can specify it when using `add`: | ||
|
||
```bash | ||
poetry add git+https://github.com/sdispater/pendulum.git@develop | ||
poetry add git+https://github.com/sdispater/[email protected] | ||
``` | ||
|
||
or make them point to a local directory or file: | ||
|
||
```bash | ||
poetry add my-package --path ../my-package/ | ||
poetry add my-package --path ../my-package/dist/my-package-0.1.0.tar.gz | ||
poetry add my-package --path ../my-package/dist/my_package-0.1.0.whl | ||
poetry add ./my-package/ | ||
poetry add ../my-package/dist/my-package-0.1.0.tar.gz | ||
poetry add ../my-package/dist/my_package-0.1.0.whl | ||
``` | ||
|
||
Path dependencies pointing to a local directory will be installed in editable mode (i.e. setuptools "develop mode"). | ||
It means that changes in the local directory will be reflected directly in environment. | ||
|
||
If you don't want the dependency to be installed in editable mode you can specify it in the `pyproject.toml` file: | ||
|
||
``` | ||
```toml | ||
[tool.poetry.dependencies] | ||
my-package = {path = "../my/path", develop = false} | ||
``` | ||
|
||
If the package(s) you want to install provide extras, you can specify them | ||
when adding the package: | ||
|
||
```bash | ||
poetry add requests[security,socks] | ||
poetry add "requests[security,socks]~=2.22.0" | ||
poetry add "git+https://github.com/pallets/[email protected][dotenv,dev]" | ||
``` | ||
|
||
### Options | ||
|
||
* `--dev (-D)`: Add package as development dependency. | ||
* `--git`: The url of the Git repository. | ||
* `--path`: The path to a dependency. | ||
* `--extras (-E)`: Extras to activate for the dependency. | ||
* `--optional` : Add as an optional dependency. | ||
* `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose). | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.