Skip to content

Poetry export does not respect groups defined in lockfile #5779

@jkgenser

Description

@jkgenser
  • 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).
  • OS version and name: Ubuntu 22.04
  • Poetry version: Poetry (version 1.2.0b2.dev0), Master@865aa94dd3393076f790d3351f6ae18483673e38
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

When running poetry export from the following pyproject.toml and poetry.lock, specifying various combinations of requirements do not result in an optional group excluded. The difference between the main group and the test group is that one of them specifies an extra from the dependency and one does not.

As you can see from the screenshot below, poetry install does what is expected given the poetry.lock and pyproject.toml. However, exporting to requirements.txt does not. Given the difference in behavior between install and export to requirements, seems like there's something broken unless the difference in behavior is intended. From what I can tell based on documentation, it should be possible to completely eject a poetry.lock file to requirements.txt since the export includes similar options to poetry install

image

Project installing

git project being installed:

https://github.com/IndicoDataSolutions/poetry-install-from/blob/main/pyproject.toml, commit d6fb91081828c1644235b247f9757f1fb0f161a0

Poetry lock contents:

The poetry lock contents indicate that the extra was picked up correctly.

[[package]]
name = "mock-git-dep"
version = "0.1.0"
description = "Test exporting poetry with dependencies and not"
category = "main"
optional = false
python-versions = "~3.10"
develop = false

[package.dependencies]
pytest = {version = "^6.2.4", optional = true}

[package.extras]
test = ["pytest (>=6.2.4,<7.0.0)"]

[package.source]
type = "git"
url = "https://github.com/IndicoDataSolutions/poetry-install-from.git"
reference = "main"
resolved_reference = "d6fb91081828c1644235b247f9757f1fb0f161a0"

Result of running poetry export against the poetry.lock

I've experimented with various attempts like,

  • not supplying any extra group args,
  • --only main --> should only get the main group. but since my test group is defined as optional, it should not be picked up
  • --without test --> If test wasn't optional, this should exclude test group.
(poetry)  ~/indico/poetry-export main poetry export -f requirements.txt --without-hashes
atomicwrites==1.4.0 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
attrs==21.4.0 ; python_version >= "3.10" and python_version < "3.11"
colorama==0.4.4 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
iniconfig==1.1.1 ; python_version >= "3.10" and python_version < "3.11"
mock-git-dep @ git+https://github.com/IndicoDataSolutions/poetry-install-from.git@main ; python_version >= "3.10" and python_version < "3.11"
packaging==21.3 ; python_version >= "3.10" and python_version < "3.11"
pluggy==1.0.0 ; python_version >= "3.10" and python_version < "3.11"
py==1.11.0 ; python_version >= "3.10" and python_version < "3.11"
pyparsing==3.0.9 ; python_version >= "3.10" and python_version < "3.11"
pytest==6.2.5 ; python_version >= "3.10" and python_version < "3.11"
toml==0.10.2 ; python_version >= "3.10" and python_version < "3.11"
(poetry)  ~/indico/poetry-export main poetry export -f requirements.txt --without-hashes --only main
atomicwrites==1.4.0 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
attrs==21.4.0 ; python_version >= "3.10" and python_version < "3.11"
colorama==0.4.4 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
iniconfig==1.1.1 ; python_version >= "3.10" and python_version < "3.11"
mock-git-dep @ git+https://github.com/IndicoDataSolutions/poetry-install-from.git@main ; python_version >= "3.10" and python_version < "3.11"
packaging==21.3 ; python_version >= "3.10" and python_version < "3.11"
pluggy==1.0.0 ; python_version >= "3.10" and python_version < "3.11"
py==1.11.0 ; python_version >= "3.10" and python_version < "3.11"
pyparsing==3.0.9 ; python_version >= "3.10" and python_version < "3.11"
pytest==6.2.5 ; python_version >= "3.10" and python_version < "3.11"
toml==0.10.2 ; python_version >= "3.10" and python_version < "3.11"
(poetry)  ~/indico/poetry-export main poetry export -f requirements.txt --without-hashes --without test
atomicwrites==1.4.0 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
attrs==21.4.0 ; python_version >= "3.10" and python_version < "3.11"
colorama==0.4.4 ; python_version >= "3.10" and python_version < "3.11" and sys_platform == "win32"
iniconfig==1.1.1 ; python_version >= "3.10" and python_version < "3.11"
mock-git-dep @ git+https://github.com/IndicoDataSolutions/poetry-install-from.git@main ; python_version >= "3.10" and python_version < "3.11"
packaging==21.3 ; python_version >= "3.10" and python_version < "3.11"
pluggy==1.0.0 ; python_version >= "3.10" and python_version < "3.11"
py==1.11.0 ; python_version >= "3.10" and python_version < "3.11"
pyparsing==3.0.9 ; python_version >= "3.10" and python_version < "3.11"
pytest==6.2.5 ; python_version >= "3.10" and python_version < "3.11"
toml==0.10.2 ; python_version >= "3.10" and python_version < "3.11"

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