cli.md (poetry-1.1.15) | : | cli.md (poetry-1.2.0) | ||
---|---|---|---|---|
skipping to change at line 28 | skipping to change at line 28 | |||
then `--help` combined with any of those can give you more information. | then `--help` combined with any of those can give you more information. | |||
## Global options | ## Global options | |||
* `--verbose (-v|vv|vvv)`: Increase the verbosity of messages: "-v" for normal o utput, "-vv" for more verbose output and "-vvv" for debug. | * `--verbose (-v|vv|vvv)`: Increase the verbosity of messages: "-v" for normal o utput, "-vv" for more verbose output and "-vvv" for debug. | |||
* `--help (-h)` : Display help information. | * `--help (-h)` : Display help information. | |||
* `--quiet (-q)` : Do not output any message. | * `--quiet (-q)` : Do not output any message. | |||
* `--ansi`: Force ANSI output. | * `--ansi`: Force ANSI output. | |||
* `--no-ansi`: Disable ANSI output. | * `--no-ansi`: Disable ANSI output. | |||
* `--version (-V)`: Display this application version. | * `--version (-V)`: Display this application version. | |||
* `--no-interaction (-n)`: Do not ask any interactive question. | ||||
* `--no-plugins`: Disables plugins. | ||||
* `--no-cache`: Disables Poetry source caches. | ||||
## new | ## new | |||
This command will help you kickstart your new Python project by creating | This command will help you kickstart your new Python project by creating | |||
a directory structure suitable for most projects. | a directory structure suitable for most projects. | |||
```bash | ```bash | |||
poetry new my-package | poetry new my-package | |||
``` | ``` | |||
will create a folder as follows: | will create a folder as follows: | |||
```text | ```text | |||
my-package | my-package | |||
├── pyproject.toml | ├── pyproject.toml | |||
├── README.rst | ├── README.md | |||
├── my_package | ├── my_package | |||
│ └── __init__.py | │ └── __init__.py | |||
└── tests | └── tests | |||
├── __init__.py | └── __init__.py | |||
└── test_my_package.py | ||||
``` | ``` | |||
If you want to name your project differently than the folder, you can pass | If you want to name your project differently than the folder, you can pass | |||
the `--name` option: | the `--name` option: | |||
```bash | ```bash | |||
poetry new my-folder --name my-package | poetry new my-folder --name my-package | |||
``` | ``` | |||
If you want to use a src folder, you can use the `--src` option: | If you want to use a src folder, you can use the `--src` option: | |||
```bash | ```bash | |||
poetry new --src my-package | poetry new --src my-package | |||
``` | ``` | |||
That will create a folder structure as follows: | That will create a folder structure as follows: | |||
```text | ```text | |||
my-package | my-package | |||
├── pyproject.toml | ├── pyproject.toml | |||
├── README.rst | ├── README.md | |||
├── src | ├── src | |||
│ └── my_package | │ └── my_package | |||
│ └── __init__.py | │ └── __init__.py | |||
└── tests | └── tests | |||
├── __init__.py | └── __init__.py | |||
└── test_my_package.py | ||||
``` | ``` | |||
The `--name` option is smart enough to detect namespace packages and create | ||||
the required structure for you. | ||||
```bash | ||||
poetry new --src --name my.package my-package | ||||
``` | ||||
will create the following structure: | ||||
```text | ||||
my-package | ||||
├── pyproject.toml | ||||
├── README.md | ||||
├── src | ||||
│ └── my | ||||
│ └── package | ||||
│ └── __init__.py | ||||
└── tests | ||||
└── __init__.py | ||||
``` | ||||
### Options | ||||
* `--name`: Set the resulting package name. | ||||
* `--src`: Use the src layout for the project. | ||||
* `--readme`: Specify the readme file extension. Default is `md`. If you intend | ||||
to publish to PyPI | ||||
keep the [recommendations for a PyPI-friendly README](https://packaging.python | ||||
.org/en/latest/guides/making-a-pypi-friendly-readme/) | ||||
in mind. | ||||
## init | ## init | |||
This command will help you create a `pyproject.toml` file interactively | This command will help you create a `pyproject.toml` file interactively | |||
by prompting you to provide basic information about your package. | by prompting you to provide basic information about your package. | |||
It will interactively ask you to fill in the fields, while using some smart defa ults. | It will interactively ask you to fill in the fields, while using some smart defa ults. | |||
```bash | ```bash | |||
poetry init | poetry init | |||
``` | ``` | |||
skipping to change at line 113 | skipping to change at line 143 | |||
```bash | ```bash | |||
poetry install | poetry install | |||
``` | ``` | |||
If there is a `poetry.lock` file in the current directory, | If there is a `poetry.lock` file in the current directory, | |||
it will use the exact versions from there instead of resolving them. | it will use the exact versions from there instead of resolving them. | |||
This ensures that everyone using the library will get the same versions of the d ependencies. | This ensures that everyone using the library will get the same versions of the d ependencies. | |||
If there is no `poetry.lock` file, Poetry will create one after dependency resol ution. | If there is no `poetry.lock` file, Poetry will create one after dependency resol ution. | |||
You can specify to the command that you do not want the development dependencies | If you want to exclude one or more dependency group for the installation, you ca | |||
installed by passing | n use | |||
the `--no-dev` option. | the `--without` option. | |||
```bash | ||||
poetry install --without test,docs | ||||
``` | ||||
{{% note %}} | ||||
The `--no-dev` option is now deprecated. You should use the `--without dev` nota | ||||
tion instead. | ||||
{{% /note %}} | ||||
You can also select optional dependency groups with the `--with` option. | ||||
```bash | ||||
poetry install --with test,docs | ||||
``` | ||||
It's also possible to only install specific dependency groups by using the `only | ||||
` option. | ||||
```bash | ||||
poetry install --only test,docs | ||||
``` | ||||
To only install the project itself with no dependencies, use the `--only-root` f | ||||
lag. | ||||
```bash | ```bash | |||
poetry install --no-dev | poetry install --only-root | |||
``` | ``` | |||
If you want to remove old dependencies no longer present in the lock file, use t | See [Dependency groups]({{< relref "managing-dependencies#dependency-groups" >}} | |||
he | ) for more information | |||
`--remove-untracked` option. | about dependency groups. | |||
If you want to synchronize your environment – and ensure it matches the lock fil | ||||
e – use the | ||||
`--sync` option. | ||||
```bash | ||||
poetry install --sync | ||||
``` | ||||
The `--sync` can be combined with group-related options: | ||||
```bash | ```bash | |||
poetry install --remove-untracked | poetry install --without dev --sync | |||
poetry install --with docs --sync | ||||
poetry install --only dev | ||||
``` | ``` | |||
You can also specify the extras you want installed | You can also specify the extras you want installed | |||
by passing the `-E|--extras` option (See [Extras]({{< relref "pyproject#extras" | by passing the `-E|--extras` option (See [Extras]({{< relref "pyproject#extras" | |||
>}}) for more info) | >}}) for more info). | |||
Pass `--all-extras` to install all defined extras for a project. | ||||
```bash | ```bash | |||
poetry install --extras "mysql pgsql" | poetry install --extras "mysql pgsql" | |||
poetry install -E mysql -E pgsql | poetry install -E mysql -E pgsql | |||
poetry install --all-extras | ||||
``` | ``` | |||
By default `poetry` will install your project's package everytime you run `insta ll`: | By default `poetry` will install your project's package every time you run `inst all`: | |||
```bash | ```bash | |||
$ poetry install | $ poetry install | |||
Installing dependencies from lock file | Installing dependencies from lock file | |||
No dependencies to install or update | No dependencies to install or update | |||
- Installing <your-package-name> (x.x.x) | - Installing <your-package-name> (x.x.x) | |||
``` | ``` | |||
If you want to skip this installation, use the `--no-root` option. | If you want to skip this installation, use the `--no-root` option. | |||
```bash | ```bash | |||
poetry install --no-root | poetry install --no-root | |||
``` | ``` | |||
### Options | ### Options | |||
* `--no-dev`: Do not install dev dependencies. | * `--without`: The dependency groups to ignore. | |||
* `--with`: The optional dependency groups to include. | ||||
* `--only`: The only dependency groups to include. | ||||
* `--only-root`: Install only the root project, exclude all dependencies. | ||||
* `--sync`: Synchronize the environment with the locked packages and the specifi | ||||
ed groups. | ||||
* `--no-root`: Do not install the root package (your project). | * `--no-root`: Do not install the root package (your project). | |||
* `--dry-run`: Output the operations but do not execute anything (implicitly ena bles --verbose). | ||||
* `--extras (-E)`: Features to install (multiple values allowed). | * `--extras (-E)`: Features to install (multiple values allowed). | |||
* `--all-extras`: Install all extra features (conflicts with --extras). | ||||
* `--no-dev`: Do not install dev dependencies. (**Deprecated**) | ||||
* `--remove-untracked`: Remove dependencies not presented in the lock file. (**D | ||||
eprecated**) | ||||
{{% note %}} | ||||
When `--only` is specified, `--with` and `--without` options are ignored. | ||||
{{% /note %}} | ||||
## update | ## update | |||
In order to get the latest versions of the dependencies and to update the `poetr y.lock` file, | In order to get the latest versions of the dependencies and to update the `poetr y.lock` file, | |||
you should use the `update` command. | you should use the `update` command. | |||
```bash | ```bash | |||
poetry update | poetry update | |||
``` | ``` | |||
skipping to change at line 182 | skipping to change at line 259 | |||
poetry update requests toml | poetry update requests toml | |||
``` | ``` | |||
Note that this will not update versions for dependencies outside their version c onstraints specified | Note that this will not update versions for dependencies outside their version c onstraints specified | |||
in the `pyproject.toml` file. In other terms, `poetry update foo` will be a no-o p if the version constraint | in the `pyproject.toml` file. In other terms, `poetry update foo` will be a no-o p if the version constraint | |||
specified for `foo` is `~2.3` or `2.3` and `2.4` is available. In order for `foo ` to be updated, you must | specified for `foo` is `~2.3` or `2.3` and `2.4` is available. In order for `foo ` to be updated, you must | |||
update the constraint, for example `^2.3`. You can do this using the `add` comma nd. | update the constraint, for example `^2.3`. You can do this using the `add` comma nd. | |||
### Options | ### Options | |||
* `--without`: The dependency groups to ignore. | ||||
* `--with`: The optional dependency groups to include. | ||||
* `--only`: The only dependency groups to include. | ||||
* `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose). | * `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose). | |||
* `--no-dev` : Do not install dev dependencies. | * `--no-dev` : Do not update the development dependencies. (**Deprecated**) | |||
* `--lock` : Do not perform install (only update the lockfile). | * `--lock` : Do not perform install (only update the lockfile). | |||
{{% note %}} | ||||
When `--only` is specified, `--with` and `--without` options are ignored. | ||||
{{% /note %}} | ||||
## add | ## add | |||
The `add` command adds required packages to your `pyproject.toml` and installs t hem. | The `add` command adds required packages to your `pyproject.toml` and installs t hem. | |||
If you do not specify a version constraint, | If you do not specify a version constraint, | |||
poetry will choose a suitable one based on the available package versions. | poetry will choose a suitable one based on the available package versions. | |||
```bash | ```bash | |||
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 | ||||
``` | ``` | |||
{{% note %}} | ||||
See the [Dependency specification]({{< relref "dependency-specification#using-th | ||||
e--operator" >}}) page for more information about the `@` operator. | ||||
{{% /note %}} | ||||
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 a | by using the specified constraint. | |||
lready | ||||
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 | |||
``` | ``` | |||
{{% note %}} | ||||
See the [Dependency specification]({{< relref "dependency-specification" >}}) fo | ||||
r more information on setting the version constraints for a package. | ||||
{{% /note %}} | ||||
You can also add `git` dependencies: | You can also add `git` dependencies: | |||
```bash | ```bash | |||
poetry add git+https://github.com/sdispater/pendulum.git | poetry add git+https://github.com/sdispater/pendulum.git | |||
``` | ``` | |||
or use ssh instead of https: | 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: | ||||
poetry add git+ssh://git@github.com:sdispater/pendulum.git | ||||
``` | ``` | |||
If you need to checkout a specific branch, tag or revision, | If you need to checkout a specific branch, tag or revision, | |||
you can specify it when using `add`: | you can specify it when using `add`: | |||
```bash | ```bash | |||
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: | ||||
poetry add git+ssh://github.com/sdispater/pendulum.git#develop | ||||
poetry add git+ssh://github.com/sdispater/pendulum.git#2.0.5 | ||||
``` | ``` | |||
or make them point to a local directory or file: | or reference a subdirectory: | |||
```bash | ||||
poetry add git+https://github.com/myorg/mypackage_with_subdirs.git@main#subdirec | ||||
tory=subdir | ||||
``` | ||||
You can also add a local directory or file: | ||||
```bash | ```bash | |||
poetry add ./my-package/ | 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.tar.gz | |||
poetry add ../my-package/dist/my_package-0.1.0.whl | poetry add ../my-package/dist/my_package-0.1.0.whl | |||
``` | ``` | |||
If you want the dependency to be installed in editable mode you can specify it i | If you want the dependency to be installed in editable mode you can use the `--e | |||
n the `pyproject.toml` file. It means that changes in the local directory will b | ditable` option. | |||
e reflected directly in environment. | ||||
```bash | ||||
poetry add --editable ./my-package/ | ||||
poetry add --editable git+ssh://github.com/sdispater/pendulum.git#develop | ||||
``` | ||||
Alternatively, you can specify it in the `pyproject.toml` file. It means that ch | ||||
anges in the local directory will be reflected directly in environment. | ||||
```toml | ```toml | |||
[tool.poetry.dependencies] | [tool.poetry.dependencies] | |||
my-package = {path = "../my/path", develop = true} | my-package = {path = "../my/path", develop = true} | |||
``` | ``` | |||
{{% note %}} | {{% note %}} | |||
Before poetry 1.1 path dependencies were installed in editable mode by default. You should always set the `develop` attribute explicit, | Before poetry 1.1 path dependencies were installed in editable mode by default. You should always set the `develop` attribute explicitly, | |||
to make sure the behavior is the same for all poetry versions. | to make sure the behavior is the same for all poetry versions. | |||
{{% /note %}} | {{% /note %}} | |||
If the package(s) you want to install provide extras, you can specify them | If the package(s) you want to install provide extras, you can specify them | |||
when adding the package: | when adding the package: | |||
```bash | ```bash | |||
poetry add requests[security,socks] | poetry add "requests[security,socks]" | |||
poetry add "requests[security,socks]~=2.22.0" | poetry add "requests[security,socks]~=2.22.0" | |||
poetry add "git+https://github.com/pallets/flask.git@1.1.1[dotenv,dev]" | poetry add "git+https://github.com/pallets/flask.git@1.1.1[dotenv,dev]" | |||
``` | ``` | |||
{{% warning %}} | ||||
Some shells may treat square braces (`[` and `]`) as special characters. It is s | ||||
uggested to always quote arguments containing these characters to prevent unexpe | ||||
cted shell expansion. | ||||
{{% /warning %}} | ||||
If you want to add a package to a specific group of dependencies, you can use th | ||||
e `--group (-G)` option: | ||||
```bash | ||||
poetry add mkdocs --group docs | ||||
``` | ||||
See [Dependency groups]({{< relref "managing-dependencies#dependency-groups" >}} | ||||
) for more information | ||||
about dependency groups. | ||||
### Options | ### Options | |||
* `--dev (-D)`: Add package as development dependency. | * `--group (-G)`: The group to add the dependency to. | |||
* `--path`: The path to a dependency. | * `--dev (-D)`: Add package as development dependency. (**Deprecated**) | |||
* `--optional` : Add as an optional dependency. | * `--editable (-e)`: Add vcs/path dependencies as editable. | |||
* `--dry-run` : Outputs the operations but will not execute anything (implicitly | * `--extras (-E)`: Extras to activate for the dependency. (multiple values allow | |||
enables --verbose). | ed) | |||
* `--lock` : Do not perform install (only update the lockfile). | * `--optional`: Add as an optional dependency. | |||
* `--python`: Python version for which the dependency must be installed. | ||||
* `--platform`: Platforms for which the dependency must be installed. | ||||
* `--source`: Name of the source to use to install the package. | ||||
* `--allow-prereleases`: Accept prereleases. | ||||
* `--dry-run`: Output the operations but do not execute anything (implicitly ena | ||||
bles --verbose). | ||||
* `--lock`: Do not perform install (only update the lockfile). | ||||
## remove | ## remove | |||
The `remove` command removes a package from the current | The `remove` command removes a package from the current | |||
list of installed packages. | list of installed packages. | |||
```bash | ```bash | |||
poetry remove pendulum | poetry remove pendulum | |||
``` | ``` | |||
If you want to remove a package from a specific group of dependencies, you can u | ||||
se the `--group (-G)` option: | ||||
```bash | ||||
poetry remove mkdocs --group docs | ||||
``` | ||||
See [Dependency groups]({{< relref "managing-dependencies#dependency-groups" >}} | ||||
) for more information | ||||
about dependency groups. | ||||
### Options | ### Options | |||
* `--dev (-D)`: Removes a package from the development dependencies. | * `--group (-G)`: The group to remove the dependency from. | |||
* `--dev (-D)`: Removes a package from the development dependencies. (**Deprecat | ||||
ed**) | ||||
* `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose). | * `--dry-run` : Outputs the operations but will not execute anything (implicitly enables --verbose). | |||
## show | ## show | |||
To list all of the available packages, you can use the `show` command. | To list all of the available packages, you can use the `show` command. | |||
```bash | ```bash | |||
poetry show | poetry show | |||
``` | ``` | |||
If you want to see the details of a certain package, you can pass the package na me. | If you want to see the details of a certain package, you can pass the package na me. | |||
```bash | ```bash | |||
poetry show pendulum | poetry show pendulum | |||
name : pendulum | name : pendulum | |||
version : 1.4.2 | version : 1.4.2 | |||
description : Python datetimes made easy | description : Python datetimes made easy | |||
dependencies: | dependencies | |||
- python-dateutil >=2.6.1 | - python-dateutil >=2.6.1 | |||
- tzlocal >=1.4 | - tzlocal >=1.4 | |||
- pytzdata >=2017.2.2 | - pytzdata >=2017.2.2 | |||
required by | ||||
- calendar >=1.4.0 | ||||
``` | ``` | |||
### Options | ### Options | |||
* `--no-dev`: Do not list the dev dependencies. | * `--without`: The dependency groups to ignore. | |||
* `--why`: When showing the full list, or a `--tree` for a single package, displ | ||||
ay why a package is included. | ||||
* `--with`: The optional dependency groups to include. | ||||
* `--only`: The only dependency groups to include. | ||||
* `--no-dev`: Do not list the dev dependencies. (**Deprecated**) | ||||
* `--tree`: List the dependencies as a tree. | * `--tree`: List the dependencies as a tree. | |||
* `--latest (-l)`: Show the latest version. | * `--latest (-l)`: Show the latest version. | |||
* `--outdated (-o)`: Show the latest version but only for packages that are outd ated. | * `--outdated (-o)`: Show the latest version but only for packages that are outd ated. | |||
* `--all (-a)`: Show all packages (even those not compatible with current system | ||||
). | ||||
{{% note %}} | ||||
When `--only` is specified, `--with` and `--without` options are ignored. | ||||
{{% /note %}} | ||||
## build | ## build | |||
The `build` command builds the source and wheels archives. | The `build` command builds the source and wheels archives. | |||
```bash | ```bash | |||
poetry build | poetry build | |||
``` | ``` | |||
Note that, at the moment, only pure python wheels are supported. | Note that, at the moment, only pure python wheels are supported. | |||
skipping to change at line 346 | skipping to change at line 510 | |||
``` | ``` | |||
It can also build the package if you pass it the `--build` option. | It can also build the package if you pass it the `--build` option. | |||
### Options | ### Options | |||
* `--repository (-r)`: The repository to register the package to (default: `pypi `). | * `--repository (-r)`: The repository to register the package to (default: `pypi `). | |||
Should match a repository name set by the [`config`](#config) command. | Should match a repository name set by the [`config`](#config) command. | |||
* `--username (-u)`: The username to access the repository. | * `--username (-u)`: The username to access the repository. | |||
* `--password (-p)`: The password to access the repository. | * `--password (-p)`: The password to access the repository. | |||
* `--cert`: Certificate authority to access the repository. | ||||
* `--client-cert`: Client certificate to access the repository. | ||||
* `--build`: Build the package before publishing. | ||||
* `--dry-run`: Perform all actions except upload the package. | * `--dry-run`: Perform all actions except upload the package. | |||
* `--skip-existing`: Ignore errors from files already existing in the repository . | ||||
## config | ## config | |||
The `config` command allows you to edit poetry config settings and repositories. | The `config` command allows you to edit poetry config settings and repositories. | |||
```bash | ```bash | |||
poetry config --list | poetry config --list | |||
``` | ``` | |||
### Usage | ### Usage | |||
skipping to change at line 369 | skipping to change at line 537 | |||
poetry config [options] [setting-key] [setting-value1] ... [setting-valueN] | poetry config [options] [setting-key] [setting-value1] ... [setting-valueN] | |||
```` | ```` | |||
`setting-key` is a configuration option name and `setting-value1` is a configura tion value. | `setting-key` is a configuration option name and `setting-value1` is a configura tion value. | |||
See [Configuration]({{< relref "configuration" >}}) for all available settings. | See [Configuration]({{< relref "configuration" >}}) for all available settings. | |||
### Options | ### Options | |||
* `--unset`: Remove the configuration element named by `setting-key`. | * `--unset`: Remove the configuration element named by `setting-key`. | |||
* `--list`: Show the list of current config variables. | * `--list`: Show the list of current config variables. | |||
* `--local`: Set/Get settings that are specific to a project (in the local confi guration file `poetry.toml`). | ||||
## run | ## run | |||
The `run` command executes the given command inside the project's virtualenv. | The `run` command executes the given command inside the project's virtualenv. | |||
```bash | ```bash | |||
poetry run python -V | poetry run python -V | |||
``` | ``` | |||
It can also execute one of the scripts defined in `pyproject.toml`. | It can also execute one of the scripts defined in `pyproject.toml`. | |||
skipping to change at line 406 | skipping to change at line 575 | |||
The `shell` command spawns a shell, | The `shell` command spawns a shell, | |||
according to the `$SHELL` environment variable, | according to the `$SHELL` environment variable, | |||
within the virtual environment. | within the virtual environment. | |||
If one doesn't exist yet, it will be created. | If one doesn't exist yet, it will be created. | |||
```bash | ```bash | |||
poetry shell | poetry shell | |||
``` | ``` | |||
Note that this command starts a new shell and activates the virtual environment. | ||||
As such, `exit` should be used to properly exit the shell and the virtual enviro | ||||
nment instead of `deactivate`. | ||||
## check | ## check | |||
The `check` command validates the structure of the `pyproject.toml` file | The `check` command validates the structure of the `pyproject.toml` file | |||
and returns a detailed report if there are any errors. | and returns a detailed report if there are any errors. | |||
{{% note %}} | ||||
This command is also available as a pre-commit hook. See [pre-commit hooks]({{< | ||||
relref "pre-commit-hooks#poetry-check">}}) for more information. | ||||
{{% /note %}} | ||||
```bash | ```bash | |||
poetry check | poetry check | |||
``` | ``` | |||
## search | ## search | |||
This command searches for packages on a remote index. | This command searches for packages on a remote index. | |||
```bash | ```bash | |||
poetry search requests pendulum | poetry search requests pendulum | |||
``` | ``` | |||
## lock | ## lock | |||
This command locks (without installing) the dependencies specified in `pyproject .toml`. | This command locks (without installing) the dependencies specified in `pyproject .toml`. | |||
{{% note %}} | {{% note %}} | |||
By default, this will lock all dependencies to the latest available compatible v ersions. To only refresh the lock file, use the `--no-update` option. | By default, this will lock all dependencies to the latest available compatible v ersions. To only refresh the lock file, use the `--no-update` option. | |||
This command is also available as a pre-commit hook. See [pre-commit hooks]({{< relref "pre-commit-hooks#poetry-lock">}}) for more information. | ||||
{{% /note %}} | {{% /note %}} | |||
```bash | ```bash | |||
poetry lock | poetry lock | |||
``` | ``` | |||
### Options | ### Options | |||
* `--check`: Verify that `poetry.lock` is consistent with `pyproject.toml` | ||||
* `--no-update`: Do not update locked versions, only refresh lock file. | * `--no-update`: Do not update locked versions, only refresh lock file. | |||
## version | ## version | |||
This command shows the current version of the project or bumps the version of | This command shows the current version of the project or bumps the version of | |||
the project and writes the new version back to `pyproject.toml` if a valid | the project and writes the new version back to `pyproject.toml` if a valid | |||
bump rule is provided. | bump rule is provided. | |||
The new version should ideally be a valid [semver](https://semver.org/) string o | The new version should be a valid [PEP 440](https://peps.python.org/pep-0440/) | |||
r a valid bump rule: | string or a valid bump rule: `patch`, `minor`, `major`, `prepatch`, `preminor`, | |||
`patch`, `minor`, `major`, `prepatch`, `preminor`, `premajor`, `prerelease`. | `premajor`, `prerelease`. | |||
{{% note %}} | ||||
If you would like to use semantic versioning for your project, please see | ||||
[here]({{< relref "libraries#versioning" >}}). | ||||
{{% /note %}} | ||||
The table below illustrates the effect of these rules with concrete examples. | The table below illustrates the effect of these rules with concrete examples. | |||
| rule | before | after | | | rule | before | after | | |||
|------------|---------------|---------------| | | ---------- |---------|---------| | |||
| major | 1.3.0 | 2.0.0 | | | major | 1.3.0 | 2.0.0 | | |||
| minor | 2.1.4 | 2.2.0 | | | minor | 2.1.4 | 2.2.0 | | |||
| patch | 4.1.1 | 4.1.2 | | | patch | 4.1.1 | 4.1.2 | | |||
| premajor | 1.0.2 | 2.0.0-alpha.0 | | | premajor | 1.0.2 | 2.0.0a0 | | |||
| preminor | 1.0.2 | 1.1.0-alpha.0 | | | preminor | 1.0.2 | 1.1.0a0 | | |||
| prepatch | 1.0.2 | 1.0.3-alpha.0 | | | prepatch | 1.0.2 | 1.0.3a0 | | |||
| prerelease | 1.0.2 | 1.0.3-alpha.0 | | | prerelease | 1.0.2 | 1.0.3a0 | | |||
| prerelease | 1.0.3-alpha.0 | 1.0.3-alpha.1 | | | prerelease | 1.0.3a0 | 1.0.3a1 | | |||
| prerelease | 1.0.3-beta.0 | 1.0.3-beta.1 | | | prerelease | 1.0.3b0 | 1.0.3b1 | | |||
## Options | ### Options | |||
* `--short (-s)`: Output the version number only. | * `--short (-s)`: Output the version number only. | |||
* `--dry-run`: Do not update pyproject.toml file. | ||||
## export | ## export | |||
This command exports the lock file to other formats. | This command exports the lock file to other formats. | |||
```bash | ```bash | |||
poetry export -f requirements.txt --output requirements.txt | poetry export -f requirements.txt --output requirements.txt | |||
``` | ``` | |||
{{% note %}} | {{% note %}} | |||
Only the `requirements.txt` format is currently supported. | This command is provided by the [Export Poetry Plugin](https://github.com/python | |||
-poetry/poetry-plugin-export) | ||||
and is also available as a pre-commit hook. See [pre-commit hooks]({{< relref "p | ||||
re-commit-hooks#poetry-export" >}}) for more information. | ||||
{{% /note %}} | ||||
{{% note %}} | ||||
Unlike the `install` command, this command only includes the project's dependenc | ||||
ies defined in the implicit `main` | ||||
group defined in `tool.poetry.dependencies` when used without specifying any opt | ||||
ions. | ||||
{{% /note %}} | {{% /note %}} | |||
### Options | ### Options | |||
* `--format (-f)`: The format to export to (default: `requirements.txt`). | * `--format (-f)`: The format to export to (default: `requirements.txt`). | |||
Currently, only `requirements.txt` is supported. | Currently, only `requirements.txt` is supported. | |||
* `--output (-o)`: The name of the output file. If omitted, print to standard | * `--output (-o)`: The name of the output file. If omitted, print to standard | |||
output. | output. | |||
* `--dev`: Include development dependencies. | * `--dev`: Include development dependencies. (**Deprecated**) | |||
* `--extras (-E)`: Extra sets of dependencies to include. | * `--extras (-E)`: Extra sets of dependencies to include. | |||
* `--without`: The dependency groups to ignore. | ||||
* `--with`: The optional dependency groups to include. | ||||
* `--only`: The only dependency groups to include. | ||||
* `--without-hashes`: Exclude hashes from the exported file. | * `--without-hashes`: Exclude hashes from the exported file. | |||
* `--without-urls`: Exclude source repository urls from the exported file. | ||||
* `--with-credentials`: Include credentials for extra indices. | * `--with-credentials`: Include credentials for extra indices. | |||
## env | ## env | |||
The `env` command regroups sub commands to interact with the virtualenvs | The `env` command regroups sub commands to interact with the virtualenvs | |||
associated with a specific project. | associated with a specific project. | |||
See [Managing environments]({{< relref "managing-environments" >}}) for more inf ormation about these commands. | See [Managing environments]({{< relref "managing-environments" >}}) for more inf ormation about these commands. | |||
## cache | ## cache | |||
The `cache` command regroups sub commands to interact with Poetry's cache. | The `cache` command regroups sub commands to interact with Poetry's cache. | |||
### cache list | ### cache list | |||
The `cache list` command lists Poetry's available caches. | The `cache list` command lists Poetry's available caches. | |||
```bash | ```bash | |||
poetry cache list | poetry cache list | |||
``` | ``` | |||
### cache clear | ||||
The `cache clear` command removes packages from a cached repository. | ||||
For example, to clear the whole cache of packages from the `pypi` repository, ru | ||||
n: | ||||
```bash | ||||
poetry cache clear pypi --all | ||||
``` | ||||
To only remove a specific package from a cache, you have to specify the cache en | ||||
try in the following form `cache:package:version`: | ||||
```bash | ||||
poetry cache clear pypi:requests:2.24.0 | ||||
``` | ||||
## source | ||||
The `source` namespace regroups sub commands to manage repository sources for a | ||||
Poetry project. | ||||
### source add | ||||
The `source add` command adds source configuration to the project. | ||||
For example, to add the `pypi-test` source, you can run: | ||||
```bash | ||||
poetry source add pypi-test https://test.pypi.org/simple/ | ||||
``` | ||||
{{% note %}} | ||||
You cannot use the name `pypi` as it is reserved for use by the default PyPI sou | ||||
rce. | ||||
{{% /note %}} | ||||
#### Options | ||||
* `--default`: Set this source as the [default]({{< relref "repositories#disabli | ||||
ng-the-pypi-repository" >}}) (disable PyPI). | ||||
* `--secondary`: Set this source as a [secondary]({{< relref "repositories#insta | ||||
ll-dependencies-from-a-private-repository" >}}) source. | ||||
{{% note %}} | ||||
You cannot set a source as both `default` and `secondary`. | ||||
{{% /note %}} | ||||
### source show | ||||
The `source show` command displays information on all configured sources for the | ||||
project. | ||||
```bash | ||||
poetry source show | ||||
``` | ||||
Optionally, you can show information of one or more sources by specifying their | ||||
names. | ||||
```bash | ||||
poetry source show pypi-test | ||||
``` | ||||
{{% note %}} | ||||
This command will only show sources configured via the `pyproject.toml` and does | ||||
not include PyPI. | ||||
{{% /note %}} | ||||
### source remove | ||||
The `source remove` command removes a configured source from your `pyproject.tom | ||||
l`. | ||||
```bash | ||||
poetry source remove pypi-test | ||||
``` | ||||
## about | ||||
The `about` command displays global information about Poetry, including the curr | ||||
ent version and version of `poetry-core`. | ||||
```bash | ||||
poetry about | ||||
``` | ||||
## help | ||||
The `help` command displays global help, or help for a specific command. | ||||
To display global help: | ||||
```bash | ||||
poetry help | ||||
``` | ||||
To display help for a specific command, for instance `show`: | ||||
```bash | ||||
poetry help show | ||||
``` | ||||
{{% note %}} | ||||
The `--help` option can also be passed to any command to get help for a specific | ||||
command. | ||||
For instance: | ||||
```bash | ||||
poetry show --help | ||||
``` | ||||
{{% /note %}} | ||||
## list | ||||
The `list` command displays all the available Poetry commands. | ||||
```bash | ||||
poetry list | ||||
``` | ||||
## self | ||||
The `self` namespace regroups sub commands to manage the Poetry installation its | ||||
elf. | ||||
{{% note %}} | ||||
Use of these commands will create the required `pyproject.toml` and `poetry.lock | ||||
` files in your | ||||
[configuration directory]({{< relref "configuration" >}}). | ||||
{{% /note %}} | ||||
### self add | ||||
The `self add` command installs Poetry plugins and make them available at runtim | ||||
e. Additionally, it can | ||||
also be used to upgrade Poetry's own dependencies or inject additional packages | ||||
into the runtime | ||||
environment | ||||
{{% note %}} | ||||
The `self add` command works exactly like the [`add` command](#add). However, is | ||||
different in that the packages | ||||
managed are for Poetry's runtime environment. | ||||
The package specification formats supported by the `self add` command are the sa | ||||
me as the ones supported | ||||
by the [`add` command](#add). | ||||
{{% /note %}} | ||||
For example, to install the `poetry-plugin-export` plugin, you can run: | ||||
```bash | ||||
poetry self add poetry-plugin-export | ||||
``` | ||||
To update to the latest `poetry-core` version, you can run: | ||||
```bash | ||||
poetry self add poetry-core@latest | ||||
``` | ||||
To add a keyring provider `artifacts-keyring`, you can run: | ||||
```bash | ||||
poetry self add artifacts-keyring | ||||
``` | ||||
#### Options | ||||
* `--editable (-e)`: Add vcs/path dependencies as editable. | ||||
* `--extras (-E)`: Extras to activate for the dependency. (multiple values allow | ||||
ed) | ||||
* `--allow-prereleases`: Accept prereleases. | ||||
* `--source`: Name of the source to use to install the package. | ||||
* `--dry-run`: Output the operations but do not execute anything (implicitly ena | ||||
bles --verbose). | ||||
### self update | ||||
The `self update` command updates Poetry version in its current runtime environm | ||||
ent. | ||||
{{% note %}} | ||||
The `self update` command works exactly like the [`update` command](#update). Ho | ||||
wever, | ||||
is different in that the packages managed are for Poetry's runtime environment. | ||||
{{% /note %}} | ||||
```bash | ||||
poetry self update | ||||
``` | ||||
#### Options | ||||
* `--preview`: Allow the installation of pre-release versions. | ||||
* `--dry-run`: Output the operations but do not execute anything (implicitly ena | ||||
bles --verbose). | ||||
### self lock | ||||
The `self lock` command reads this Poetry installation's system `pyproject.toml` | ||||
file. The system | ||||
dependencies are locked in the corresponding `poetry.lock` file. | ||||
```bash | ||||
poetry self lock | ||||
``` | ||||
#### Options | ||||
* `--check`: Verify that `poetry.lock` is consistent with `pyproject.toml` | ||||
* `--no-update`: Do not update locked versions, only refresh lock file. | ||||
### self show | ||||
The `self show` command behaves similar to the show command, but | ||||
working within Poetry's runtime environment. This lists all packages installed w | ||||
ithin | ||||
the Poetry install environment. | ||||
To show only additional packages that have been added via self add and their | ||||
dependencies use `self show --addons`. | ||||
```bash | ||||
poetry self show | ||||
``` | ||||
#### Options | ||||
* `--addons`: List only add-on packages installed. | ||||
* `--tree`: List the dependencies as a tree. | ||||
* `--latest (-l)`: Show the latest version. | ||||
* `--outdated (-o)`: Show the latest version but only for packages that are outd | ||||
ated. | ||||
### self show plugins | ||||
The `self show plugins` command lists all the currently installed plugins. | ||||
```bash | ||||
poetry self show plugins | ||||
``` | ||||
### self remove | ||||
The `self remove` command removes an installed addon package. | ||||
```bash | ||||
poetry self remove poetry-plugin-export | ||||
``` | ||||
#### Options | ||||
* `--dry-run`: Outputs the operations but will not execute anything (implicitly | ||||
enables --verbose). | ||||
### self install | ||||
The `self install` command ensures all additional packages specified are install | ||||
ed in the current | ||||
runtime environment. | ||||
{{% note %}} | ||||
The `self install` command works similar to the [`install` command](#install). H | ||||
owever, | ||||
is different in that the packages managed are for Poetry's runtime environment. | ||||
{{% /note %}} | ||||
```bash | ||||
poetry self install --sync | ||||
``` | ||||
#### Options | ||||
* `--sync`: Synchronize the environment with the locked packages and the specifi | ||||
ed groups. | ||||
* `--dry-run`: Output the operations but do not execute anything (implicitly ena | ||||
bles --verbose). | ||||
End of changes. 56 change blocks. | ||||
55 lines changed or deleted | 278 lines changed or added |