You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `install` command reads the `pyproject.toml` file from the current project,
143
143
resolves the dependencies, and installs them.
144
144
145
+
{{% note %}}
146
+
Normally, you should prefer `poetry sync` to `poetry install` to avoid untracked outdated packages.
147
+
However, if you have set `virtualenvs.create = false` to install dependencies into your system environment,
148
+
which is discouraged, or `virtualenvs.options.system-site-packages = true` to make
149
+
system site-packages available in your virtual environment, you should use `poetry install`
150
+
because `poetry sync` will normally not work well in these cases.
151
+
{{% /note %}}
152
+
145
153
```bash
146
154
poetry install
147
155
```
@@ -186,21 +194,6 @@ poetry install --only-root
186
194
See [Dependency groups]({{< relref "managing-dependencies#dependency-groups" >}}) for more information
187
195
about dependency groups.
188
196
189
-
If you want to synchronize your environment – and ensure it matches the lock file – use the
190
-
`--sync` option.
191
-
192
-
```bash
193
-
poetry install --sync
194
-
```
195
-
196
-
The `--sync` can be combined with group-related options:
197
-
198
-
```bash
199
-
poetry install --without dev --sync
200
-
poetry install --with docs --sync
201
-
poetry install --only dev --sync
202
-
```
203
-
204
197
You can also specify the extras you want installed
205
198
by passing the `-E|--extras` option (See [Extras]({{< relref "pyproject#extras" >}}) for more info).
206
199
Pass `--all-extras` to install all defined extras for a project.
@@ -211,7 +204,7 @@ poetry install -E mysql -E pgsql
211
204
poetry install --all-extras
212
205
```
213
206
214
-
Extras are not sensitive to `--sync`. Any extras not specified will always be removed.
207
+
Any extras not specified will always be removed.
215
208
216
209
```bash
217
210
poetry install --extras "A B"# C is removed
@@ -258,7 +251,7 @@ poetry install --compile
258
251
*`--with`: The optional dependency groups to include.
259
252
*`--only`: The only dependency groups to include.
260
253
*`--only-root`: Install only the root project, exclude all dependencies.
261
-
*`--sync`: Synchronize the environment with the locked packages and the specified groups.
254
+
*`--sync`: Synchronize the environment with the locked packages and the specified groups. (**Deprecated**, use `poetry sync` instead)
262
255
*`--no-root`: Do not install the root package (your project).
263
256
*`--no-directory`: Skip all directory path dependencies (including transitive ones).
264
257
*`--dry-run`: Output the operations but do not execute anything (implicitly enables `--verbose`).
@@ -275,15 +268,119 @@ When `--only` is specified, `--with` and `--without` options are ignored.
275
268
## sync
276
269
277
270
The `sync` command makes sure that the project's environment is in sync with the `poetry.lock` file.
278
-
It is equivalent to running `poetry install --sync` and provides the same options
279
-
(except for `--sync`) as [install]({{< relref "#install" >}}).
271
+
It is similar to `poetry install` but it additionally removes packages that are not tracked in the lock file.
272
+
273
+
```bash
274
+
poetry sync
275
+
```
276
+
277
+
If there is a `poetry.lock` file in the current directory,
278
+
it will use the exact versions from there instead of resolving them.
279
+
This ensures that everyone using the library will get the same versions of the dependencies.
280
+
281
+
If there is no `poetry.lock` file, Poetry will create one after dependency resolution.
282
+
283
+
If you want to exclude one or more dependency groups for the installation, you can use
284
+
the `--without` option.
285
+
286
+
```bash
287
+
poetry sync --without test,docs
288
+
```
289
+
290
+
You can also select optional dependency groups with the `--with` option.
291
+
292
+
```bash
293
+
poetry sync --with test,docs
294
+
```
295
+
296
+
To install all dependency groups including the optional groups, use the ``--all-groups`` flag.
297
+
298
+
```bash
299
+
poetry sync --all-groups
300
+
```
301
+
302
+
It's also possible to only install specific dependency groups by using the `only` option.
303
+
304
+
```bash
305
+
poetry sync --only test,docs
306
+
```
307
+
308
+
To only install the project itself with no dependencies, use the `--only-root` flag.
309
+
310
+
```bash
311
+
poetry sync --only-root
312
+
```
313
+
314
+
See [Dependency groups]({{< relref "managing-dependencies#dependency-groups" >}}) for more information
315
+
about dependency groups.
316
+
317
+
You can also specify the extras you want installed
318
+
by passing the `-E|--extras` option (See [Extras]({{< relref "pyproject#extras" >}}) for more info).
319
+
Pass `--all-extras` to install all defined extras for a project.
320
+
321
+
```bash
322
+
poetry sync --extras "mysql pgsql"
323
+
poetry sync -E mysql -E pgsql
324
+
poetry sync --all-extras
325
+
```
326
+
327
+
Any extras not specified will always be removed.
328
+
329
+
```bash
330
+
poetry sync --extras "A B"# C is removed
331
+
```
332
+
333
+
By default `poetry` will install your project's package every time you run `sync`:
334
+
335
+
```bash
336
+
$ poetry sync
337
+
Installing dependencies from lock file
338
+
339
+
No dependencies to install or update
340
+
341
+
- Installing <your-package-name> (x.x.x)
342
+
```
343
+
344
+
If you want to skip this installation, use the `--no-root` option.
345
+
346
+
```bash
347
+
poetry sync --no-root
348
+
```
349
+
350
+
Similar to `--no-root` you can use `--no-directory` to skip directory path dependencies:
351
+
352
+
```bash
353
+
poetry sync --no-directory
354
+
```
355
+
356
+
This is mainly useful for caching in CI or when building Docker images. See the [FAQ entry]({{< relref "faq#poetry-busts-my-docker-cache-because-it-requires-me-to-copy-my-source-files-in-before-installing-3rd-party-dependencies" >}}) for more information on this option.
357
+
358
+
By default `poetry` does not compile Python source files to bytecode during installation.
359
+
This speeds up the installation process, but the first execution may take a little more
360
+
time because Python then compiles source files to bytecode automatically.
361
+
If you want to compile source files to bytecode during installation,
362
+
you can use the `--compile` option:
363
+
364
+
```bash
365
+
poetry sync --compile
366
+
```
367
+
368
+
### Options
369
+
370
+
*`--without`: The dependency groups to ignore.
371
+
*`--with`: The optional dependency groups to include.
372
+
*`--only`: The only dependency groups to include.
373
+
*`--only-root`: Install only the root project, exclude all dependencies.
374
+
*`--no-root`: Do not install the root package (your project).
375
+
*`--no-directory`: Skip all directory path dependencies (including transitive ones).
376
+
*`--dry-run`: Output the operations but do not execute anything (implicitly enables `--verbose`).
377
+
*`--extras (-E)`: Features to install (multiple values allowed).
378
+
*`--all-extras`: Install all extra features (conflicts with `--extras`).
379
+
*`--all-groups`: Install dependencies from all groups (conflicts with `--only`, `--with`, and `--without`).
380
+
*`--compile`: Compile Python source files to bytecode.
280
381
281
382
{{% note %}}
282
-
Normally, you should prefer `poetry sync` to `poetry install` to avoid untracked outdated packages.
283
-
However, if you have set `virtualenvs.create = false` to install dependencies into your system environment,
284
-
which is discouraged, or `virtualenvs.options.system-site-packages = true` to make
285
-
system site-packages available in your virtual environment, you should use `poetry install`
286
-
because `poetry sync` will normally not work well in these cases.
383
+
When `--only` is specified, `--with` and `--without` options are ignored.
287
384
{{% /note %}}
288
385
289
386
@@ -1039,16 +1136,34 @@ runtime environment.
1039
1136
1040
1137
{{% note %}}
1041
1138
The `self install` command works similar to the [`install` command](#install). However,
1042
-
is different in that the packages managed are for Poetry's runtime environment.
1139
+
it is different in that the packages managed are for Poetry's runtime environment.
1043
1140
{{% /note %}}
1044
1141
1045
1142
```bash
1046
-
poetry self install --sync
1143
+
poetry self install
1144
+
```
1145
+
1146
+
#### Options
1147
+
1148
+
*`--sync`: Synchronize the environment with the locked packages and the specified groups. (**Deprecated**, use `poetry self sync` instead)
1149
+
*`--dry-run`: Output the operations but do not execute anything (implicitly enables `--verbose`).
1150
+
1151
+
### self sync
1152
+
1153
+
The `self sync` command ensures all additional (and no other) packages specified
1154
+
are installed in the current runtime environment.
1155
+
1156
+
{{% note %}}
1157
+
The `self sync` command works similar to the [`sync` command](#sync). However,
1158
+
it is different in that the packages managed are for Poetry's runtime environment.
1159
+
{{% /note %}}
1160
+
1161
+
```bash
1162
+
poetry self sync
1047
1163
```
1048
1164
1049
1165
#### Options
1050
1166
1051
-
*`--sync`: Synchronize the environment with the locked packages and the specified groups.
1052
1167
*`--dry-run`: Output the operations but do not execute anything (implicitly enables `--verbose`).
0 commit comments