Skip to content

Commit

Permalink
add root-only install option
Browse files Browse the repository at this point in the history
  • Loading branch information
calmdown13 committed Feb 9, 2021
1 parent cddd675 commit 2bb0cc5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
9 changes: 9 additions & 0 deletions docs/docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ If you want to install the dependencies only, run the `install` command with the
poetry install --no-root
```

### Installing root package only

If you want to install the current project only, without resolving any
dependencies, run the `install` command with the `--root-only` flag:

```bash
poetry install --root-only
```

## Updating dependencies to their latest versions

As mentioned above, the `poetry.lock` file prevents you from automatically getting the latest versions
Expand Down
9 changes: 9 additions & 0 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,20 @@ poetry install --no-root
Installation of your project's package is also skipped when the `--dev-only`
option is passed.


If you only want to install your project's package, without resolving any
dependencies, use the `--root-only` option.

```bash
poetry install --root-only
```

### Options

* `--no-dev`: Do not install dev dependencies.
* `--dev-only`: Only install dev dependencies.
* `--no-root`: Do not install the root package (your project).
* `--root-only`: Only install the root package (your project).
* `--dry-run`: Output the operations but do not execute anything (implicitly enables --verbose).
* `--remove-untracked`: Remove dependencies not presented in the lock file
* `--extras (-E)`: Features to install (multiple values allowed).
Expand Down
40 changes: 22 additions & 18 deletions poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class InstallCommand(InstallerCommand):
option(
"no-root", None, "Do not install the root package (the current project)."
),
option(
"root-only", None, "Only install the root package (the current project)."
),
option(
"dry-run",
None,
Expand Down Expand Up @@ -54,28 +57,29 @@ def handle(self) -> int:
from poetry.core.masonry.utils.module import ModuleOrPackageNotFound
from poetry.masonry.builders import EditableBuilder

self._installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)
if not self.option("root-only"):
self._installer.use_executor(
self.poetry.config.get("experimental.new-installer", False)
)

extras = []
for extra in self.option("extras"):
if " " in extra:
extras += [e.strip() for e in extra.split(" ")]
else:
extras.append(extra)
extras = []
for extra in self.option("extras"):
if " " in extra:
extras += [e.strip() for e in extra.split(" ")]
else:
extras.append(extra)

self._installer.extras(extras)
self._installer.dev_mode(not self.option("no-dev"))
self._installer.dev_only(self.option("dev-only"))
self._installer.dry_run(self.option("dry-run"))
self._installer.remove_untracked(self.option("remove-untracked"))
self._installer.verbose(self._io.is_verbose())
self._installer.extras(extras)
self._installer.dev_mode(not self.option("no-dev"))
self._installer.dev_only(self.option("dev-only"))
self._installer.dry_run(self.option("dry-run"))
self._installer.remove_untracked(self.option("remove-untracked"))
self._installer.verbose(self._io.is_verbose())

return_code = self._installer.run()
return_code = self._installer.run()

if return_code != 0:
return return_code
if return_code != 0:
return return_code

if self.option("no-root") or self.option("dev-only"):
return 0
Expand Down

0 comments on commit 2bb0cc5

Please sign in to comment.