Skip to content

Commit

Permalink
Rename --no-path -> --no-directory
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangb committed Mar 6, 2023
1 parent 7e24af1 commit 0d502a1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 30 deletions.
9 changes: 5 additions & 4 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ If you want to skip this installation, use the `--no-root` option.
poetry install --no-root
```

Similar to `--no-root` you can use `--no-path` to skip path dependencies:
Similar to `--no-root` you can use `--no-directory` to skip path dependencies:

```bash
poetry install --no-path
poetry install --no-directory
```

By default `poetry` does not compile Python source files to bytecode during installation.
This speeds up the installation process, but the first execution may take a little more
Expand All @@ -244,7 +245,7 @@ poetry install --compile
The `--compile` option has no effect if `installer.modern-installation`
is set to `false` because the old installer always compiles source files to bytecode.
{{% /note %}}
```


### Options

Expand All @@ -254,7 +255,7 @@ is set to `false` because the old installer always compiles source files to byte
* `--only-root`: Install only the root project, exclude all dependencies.
* `--sync`: Synchronize the environment with the locked packages and the specified groups.
* `--no-root`: Do not install the root package (your project).
* `--no-path`: Skip all path dependencies (including transitive ones).
* `--no-directory`: Skip all directory path dependencies (including transitive ones).
* `--dry-run`: Output the operations but do not execute anything (implicitly enables --verbose).
* `--extras (-E)`: Features to install (multiple values allowed).
* `--all-extras`: Install all extra features (conflicts with --extras).
Expand Down
4 changes: 2 additions & 2 deletions docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ This might look something like this:
```text
FROM python
COPY pyproject.toml poetry.lock .
RUN pip install poetry && poetry install --no-root --no-path
RUN pip install poetry && poetry install --no-root --no-directory
COPY src/ ./src
RUN poetry install --no-dev
```

The two key options we are using here are `--no-root` (skips installing the project source) and `--no-path` (skips installing any local path dependencies, you can skip this if you don't have any).
The two key options we are using here are `--no-root` (skips installing the project source) and `--no-directory` (skips installing any local directory path dependencies, you can skip this if you don't have any).
[More information on the options available for `poetry install`]({{< relref "cli#install" >}}).
9 changes: 5 additions & 4 deletions src/poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ class InstallCommand(InstallerCommand):
"no-root", None, "Do not install the root package (the current project)."
),
option(
"no-path",
"no-directory",
None,
(
"Do not install any path dependencies "
"(useful to install dependencies without source code, e.g. for caching)"
"Do not install any directory path dependencies (ones using `package ="
' { path = "..." }`\'; useful to install dependencies without source'
" code, e.g. for caching of Docker layers)"
),
flag=True,
multiple=False,
Expand Down Expand Up @@ -158,7 +159,7 @@ def handle(self) -> int:
with_synchronization = True

self.installer.only_groups(self.activated_groups)
self.installer.skip_path(self.option("no-path"))
self.installer.skip_directory(self.option("no-directory"))
self.installer.dry_run(self.option("dry-run"))
self.installer.requires_synchronization(with_synchronization)
self.installer.executor.enable_bytecode_compilation(self.option("compile"))
Expand Down
8 changes: 4 additions & 4 deletions src/poetry/installation/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(
self._verbose = False
self._write_lock = True
self._groups: Iterable[str] | None = None
self._skip_path = False
self._skip_directory = False

self._execute_operations = True
self._lock = False
Expand Down Expand Up @@ -151,8 +151,8 @@ def update(self, update: bool = True) -> Installer:

return self

def skip_path(self, skip_path: bool = False) -> Installer:
self._skip_path = skip_path
def skip_directory(self, skip_directory: bool = False) -> Installer:
self._skip_directory = skip_directory

return self

Expand Down Expand Up @@ -342,7 +342,7 @@ def _do_install(self) -> int:
ops = solver.solve(use_latest=self._whitelist).calculate_operations(
with_uninstalls=self._requires_synchronization,
synchronize=self._requires_synchronization,
skip_path=self._skip_path,
skip_directory=self._skip_directory,
)

if not self._requires_synchronization:
Expand Down
4 changes: 2 additions & 2 deletions src/poetry/puzzle/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def calculate_operations(
self,
with_uninstalls: bool = True,
synchronize: bool = False,
skip_path: bool = False,
skip_directory: bool = False,
) -> list[Operation]:
from poetry.installation.operations import Install
from poetry.installation.operations import Uninstall
Expand Down Expand Up @@ -74,7 +74,7 @@ def calculate_operations(
break

if not installed and (
not skip_path or result_package.source_type != "directory"
not skip_directory or result_package.source_type != "directory"
):
operations.append(Install(result_package, priority=priority))

Expand Down
12 changes: 0 additions & 12 deletions tests/console/commands/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,18 +285,6 @@ def test_dry_run_populates_installer(tester: CommandTester, mocker: MockerFixtur
assert tester.command.installer._dry_run is True


def test_no_path_is_passed_to_installer(tester: CommandTester, mocker: MockerFixture):
"""
The --no-root options is passed to the installer.
"""

mocker.patch.object(tester.command.installer, "run", return_value=1)

tester.execute("--no-path")

assert tester.command.installer._skip_path is True


def test_dry_run_does_not_build(tester: CommandTester, mocker: MockerFixture):
mocker.patch.object(tester.command.installer, "run", return_value=0)
mocked_editable_builder = mocker.patch(
Expand Down
4 changes: 2 additions & 2 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1291,7 +1291,7 @@ def test_run_installs_with_local_poetry_directory_transitive_no_path(
tmpdir: Path,
fixture_dir: FixtureDirGetter,
):
"""When we set Installer.skip_path(True) no path dependencies should
"""When we set Installer.skip_directory(True) no path dependencies should
be installed (including transitive dependencies)
"""
root_dir = fixture_dir("directory")
Expand All @@ -1309,7 +1309,7 @@ def test_run_installs_with_local_poetry_directory_transitive_no_path(
repo.add_package(get_package("pendulum", "1.4.4"))
repo.add_package(get_package("cachy", "0.2.0"))

installer.skip_path(True)
installer.skip_directory(True)

installer.run()

Expand Down

0 comments on commit 0d502a1

Please sign in to comment.