diff --git a/docs/cli.md b/docs/cli.md index 073d975fee9..191ce2c2883 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -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 @@ -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 @@ -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). diff --git a/docs/faq.md b/docs/faq.md index 3ef0b7e8dc4..3f5fc8533a5 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -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" >}}). diff --git a/src/poetry/console/commands/install.py b/src/poetry/console/commands/install.py index 7cde2f468b1..9bebfba3ba0 100644 --- a/src/poetry/console/commands/install.py +++ b/src/poetry/console/commands/install.py @@ -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, @@ -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")) diff --git a/src/poetry/installation/installer.py b/src/poetry/installation/installer.py index bb39f93fc70..dcd8ef2df31 100644 --- a/src/poetry/installation/installer.py +++ b/src/poetry/installation/installer.py @@ -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 @@ -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 @@ -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: diff --git a/src/poetry/puzzle/transaction.py b/src/poetry/puzzle/transaction.py index 947c0af5798..679baa98980 100644 --- a/src/poetry/puzzle/transaction.py +++ b/src/poetry/puzzle/transaction.py @@ -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 @@ -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)) diff --git a/tests/console/commands/test_install.py b/tests/console/commands/test_install.py index b40e670ed9b..8735fb13204 100644 --- a/tests/console/commands/test_install.py +++ b/tests/console/commands/test_install.py @@ -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( @@ -368,6 +356,6 @@ def test_no_path_is_passed_to_installer(tester: CommandTester, mocker: MockerFix mocker.patch.object(tester.command.installer, "run", return_value=1) - tester.execute("--no-path") + tester.execute("--no-directory") assert tester.command.installer._skip_path is True diff --git a/tests/installation/test_installer.py b/tests/installation/test_installer.py index 6947a5fc863..9462ff8cb5c 100644 --- a/tests/installation/test_installer.py +++ b/tests/installation/test_installer.py @@ -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") @@ -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()