Skip to content

poetry install --without installs optional dependency groups #4577

@pmav99

Description

@pmav99
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
Poetry
Version: 1.2.0a2
Python:  3.9.7

Virtualenv
Python:         3.8.12
Implementation: CPython
Path:           /tmp/aaa/.venv
Valid:          True

System
Platform: linux
OS:       posix
Python:   /usr

This is somewhat similar to #4401 but that was about poetry 1.1 so I opened a different ticket.

Issue

Let's say we have two optional groups, test and foo. foo does not contain any packages, but this is not important here. I am just keep it empty to speed up dependency resolution etc.

[tool.poetry]
name = "aaa"
version = "0.1.0"
description = ""
authors = ["pmav99 <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"

[tool.poetry.group.test]
optional = true
[tool.poetry.group.foo]
optional = true

[tool.poetry.group.test.dependencies]
pytest= "*"

[tool.poetry.group.foo.dependencies]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

Running poetry update followed by poetry install works great, i.e. pytest will not be installed since nobody asked to install the group test.:

poetry update --quiet
poetry install --quiet
python -mpytest --help || echo 'pytest not installed'

If we try to run poetry install --with foo then still everything works as expected. I.e. pytest remains non-installed.

poetry install --with foo
python -mpytest --help || echo 'pytest not installed'

Nevertheless, when we try to run poetry install --without foo, then the dependencies of group test get installed too!

$ poetry install --without foo
Installing dependencies from lock file

Package operations: 8 installs, 0 updates, 0 removals

  • Installing pyparsing (2.4.7)
  • Installing attrs (21.2.0)
  • Installing iniconfig (1.1.1)
  • Installing packaging (21.0)
  • Installing pluggy (1.0.0)
  • Installing py (1.10.0)
  • Installing toml (0.10.2)
  • Installing pytest (6.2.5)

$ python -c 'import pytest' && echo 'wtf???'
wtf???

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions