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

Optional dependencies incorrectly being exported w/ optional groups and extras #7743

Closed
4 tasks done
vwxyzjn opened this issue Mar 30, 2023 · 2 comments
Closed
4 tasks done
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@vwxyzjn
Copy link

vwxyzjn commented Mar 30, 2023

Poetry
Version: 1.4.1
Python:  3.9.5

Virtualenv
Python:         3.9.5
Implementation: CPython
Path:           /home/costa/.cache/pypoetry/virtualenvs/poetry14bug-7MQTjeBG-py3.9
Executable:     /home/costa/.cache/pypoetry/virtualenvs/poetry14bug-7MQTjeBG-py3.9/bin/python
Valid:          True

System
Platform:   linux
OS:         posix
Python:     3.9.5
Path:       /home/costa/.pyenv/versions/3.9.5
Executable: /home/costa/.pyenv/versions/3.9.5/bin/python3.9
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

During poetry export, extras and optional groups do not work properly with each other. While poetry export works properly with either optional groups or extras, if I don't use extras, my pypi build do not have extra dependencies. If I don't use dependency groups, when calling poetry install -E "A B" will remove extra dependency "C", unlike poetry install --with.

❌ Have both extras and groups

[tool.poetry]
name = "poetry14bug"
version = "0.1.0"
description = ""
authors = ["Costa Huang <costa.huang@outlook.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
numpy = {version = "^1.24.2", optional = true}
pandas = {version = "^1.5.3", optional = true}


[tool.poetry.group.A]
optional = true
[tool.poetry.group.A.dependencies]
numpy = "^1.24.2"

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

[tool.poetry.extras]
As = ["numpy", "pandas"]

Note that numpy is an optional dependency. When running poetry export --without-hashes -o d.txt --without=A I get the following, which included the optional numpy.

numpy==1.24.2 ; python_version >= "3.9" and python_version < "4.0"

✅ Have only extras

[tool.poetry]
name = "poetry14bug"
version = "0.1.0"
description = ""
authors = ["Costa Huang <costa.huang@outlook.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.9"
numpy = {version = "^1.24.2", optional = true}
pandas = {version = "^1.5.3", optional = true}

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

[tool.poetry.extras]
As = ["numpy", "pandas"]

poetry export --without-hashes -o d.txt follows expectation and exports an empty requirements.txt.

✅ Have only extra groups

[tool.poetry]
name = "poetry14bug"
version = "0.1.0"
description = ""
authors = ["Costa Huang <costa.huang@outlook.com>"]
readme = "README.md"

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

[tool.poetry.group.A]
optional = true
[tool.poetry.group.A.dependencies]
numpy = "^1.24.2"

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

poetry export --without-hashes -o d.txt follows expectation and exports an empty requirements.txt.

@vwxyzjn vwxyzjn added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 30, 2023
@dimbleby
Copy link
Contributor

this should be reported in https://github.com/python-poetry/poetry-plugin-export, not here

but no need to bother because it's a duplicate of python-poetry/poetry-plugin-export#34, in particular python-poetry/poetry-plugin-export#34 (comment)

please close

@vwxyzjn vwxyzjn closed this as completed Mar 30, 2023
Copy link

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 Feb 29, 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 status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants