Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-E ignored when using poetry.group #4891

Closed
Conchylicultor opened this issue Dec 14, 2021 · 4 comments
Closed

-E ignored when using poetry.group #4891

Conchylicultor opened this issue Dec 14, 2021 · 4 comments
Labels
kind/bug Something isn't working as expected

Comments

@Conchylicultor
Copy link

Conchylicultor commented Dec 14, 2021

  • OS version and name: Debian
  • Poetry version: 1.2.0a2
[tool.poetry]
name = "tmp-poetry"
version = "0.1.0"
description = ""
authors = ["xyz <xyz@gmail.com>"]

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

# Bellow is the bug

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

[tool.poetry.group.group0]
optional = true

[tool.poetry.group.group0.dependencies]
numpy = "*"

[tool.poetry.extras]
numpy_extra = ["numpy"]

Issue

When [tool.poetry.extras] is used to refer to deps defined inside [tool.poetry.group.group0.dependencies], those deps are ignored.

Reproduction instrutions:

poetry install -E numpy_extra

I would expect the command to install tmp-poetry[numpy_extra] which should install numpy. However, this silently fail to install the package:

Display:

Creating virtualenv tmp-poetry-S27UDbn2-py3.9 in ~/.cache/pypoetry/virtualenvs
Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Installing the current project: tmp-poetry (0.1.0)

The extra deps is ignored and not installed, poetry show will display nothing.
poetry run python -c "import numpy" will fail with ModuleNotFoundError

Note: removing the groups and using instead numpy={version="*", optional=true} will work.

@Conchylicultor Conchylicultor added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 14, 2021
@finswimmer
Copy link
Member

Hello @Conchylicultor,

this is expected. Dependency groups and extras are different concept. You cannot mix them.

Extras are a way in thy python world to define a set of dependencies, that will bring extra functionality to your package during run time.

Dependency groups are a concept by poetry to define different set of dependency that you only need during development, like linter or testing framework.

So you must ask yourself: Do I need it this dependencies during runtime or only during development? For the first case use extras, for the later use dependency groups.

fin swimmer

@Conchylicultor
Copy link
Author

Thanks for the fast answer, However, your answer seems to contradict the doc you linked:

Poetry provides a way to organize your dependencies by groups. For instance, you might have dependencies that are only needed to test your project or to build the documentation.
Think of dependency groups as labels associated with your dependencies: they don’t have any bearings on whether their dependencies will be resolved and installed by default, they are simply a way to organize the dependencies logically.

The doc say those deps can be used for tests but not that they have to.

Additionally, even global dependencies have a "default" group, which indicates group are not limited to developpement. From the doc:

The dependencies declared in tool.poetry.dependencies are part of an implicit default group.

Additionally, other users seems to understand like me that group and extras features are complementary features which can be used jointly:
#4842

@Conchylicultor
Copy link
Author

At minima, poetry should raise an explicit error message. I just spend half a day trying to debug this issue.

Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants