LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

poetry-add

Add dependencies to a Poetry project

TLDR

Add a dependency
$ poetry add [package]
copy
Add specific version
$ poetry add [package]@[1.0.0]
copy
Add development dependency
$ poetry add --group dev [package]
copy
Add from git
$ poetry add git+https://github.com/[user]/[repo].git
copy
Add multiple packages
$ poetry add [package1] [package2]
copy

SYNOPSIS

poetry add [options] packages...

DESCRIPTION

poetry add adds dependencies to pyproject.toml and installs them. It resolves version constraints and updates the lock file automatically.

PARAMETERS

--group, -G group

Dependency group to add the package to (e.g., dev, test).
--dev, -D
Shortcut for `--group dev`.
--optional
Add as an optional dependency to an extra.
--dry-run
Output the operations without executing them.
--editable, -e
Add vcs/path dependencies as editable.
--extras, -E extras
Extras to activate for the dependency (multiple values allowed).
--source source
Name of the source to use to install the package.
--python version
Python version constraint for which the dependency must be installed.
--platform platform
Platforms for which the dependency must be installed.
--markers markers
Environment markers describing when the dependency should be installed.
--allow-prereleases
Accept prereleases.
--lock
Do not perform install; only update the lockfile.

EXAMPLES

$ # Add latest version
poetry add requests

# Add with version constraint
poetry add "django>=4.0"

# Add dev dependency
poetry add --group dev pytest

# Add from git branch
poetry add git+https://github.com/user/repo.git#branch

# Add with extras
poetry add fastapi --extras all

# Add local package
poetry add ../my-package --editable
copy

VERSION CONSTRAINTS

$ package         - Latest
package@1.0.0   - Exact version
package@^1.0    - Compatible (>=1.0 <2.0)
package@~1.0    - Approximately (>=1.0 <1.1)
copy

INSTALL

sudo dnf install poetry
copy
sudo apk add poetry
copy
brew install poetry
copy
nix profile install nixpkgs#poetry
copy

CAVEATS

Modifies pyproject.toml and poetry.lock. Use --dry-run to preview changes.

HISTORY

poetry add is part of Poetry, the Python dependency manager created by Sébastien Eustace.

SEE ALSO

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid