What are use cases for "poetry install --no-root"?
Asked Answered
C

2

7

I already read the documentation in which it says

The current project is installed in editable mode by default.

If you want to install the dependencies only, run the install command with the --no-root flag:

What does install --no-root do?

In which cases would a user or developer use this instead of the normal install?

Should I use --no-root while still developing?

And if I want to install the project itself (one of the explanations) later, how can I do this?

Cocytus answered 4/1, 2024 at 11:0 Comment(4)
That's a good question! I've never understood why one need --no-root and until now no one could explain it to me. The only use case I've found for me so far is python-poetry.org/docs/faq/#usecase-2Hype
@Hype Maybe things like Django applications are a use case (they do not need to be installed, but their dependencies do need to be installed). -- In general there seems to be a need for projects that do not get built into a wheel, see this discussion (and other related threads) if you have not seen it yet.Brookins
Adding to @sinoroc's comment: In code bases using $NON_PYTHON_LANGUAGE you might still want to use Python here and there for scripting purposes (e.g. build scripts and CI & CD jobs and such). In such cases, you won't have a coherent application (let alone a package or a wheel) but will still want to configure your Python environment somehow.Myriammyriameter
The comments on Github mention many other reasons why you might want to use --no-root.Myriammyriameter
C
6

From personal experience, I can think of a couple of use cases why for the --no-root option.

  1. To enhance a CI/CD pipeline. In that case, you'd be looking at having some sort of cache for the dependencies so that if the versions of the dependencies are unchanged, the installation is done from cache and the action sped up. Indeed, looking at the following:
- run: poetry install --no-interaction --no-root
   if: steps.cache-deps.outputs.cache-hit != 'true'

it appears in some 250 github actions. This is almost always followed by - run: poetry install --no-interaction for the actual package.

  1. To separate layers of dependencies in cloud applications. For example, you may want to isolate your own package (which gets updated more often) from its dependencies in lambda layers in aws
Clintonclintonia answered 26/1, 2024 at 9:20 Comment(0)
F
-1

--no-interaction means don't prompt for any input during installation of dependencies. Its useful when packages are installing in automated environment

--no-root means install dependency from pyproject.toml except the project

--no-ansi means output should be plain text without ANSI colour codes

Fullback answered 30/8, 2024 at 21:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.