Skip to content

markers in poetry.lock are inaccurate #10239

@joaopmatias

Description

@joaopmatias

Description

Issue (Bug)

The markers in poetry.lock show the wrong value sometimes. Moreover, this behavior can impact poetry-plugin-export that relies on that value since version 1.9.0 of the plugin.

As shown in the example below, it gives "platform_system == \"Linux\"" when no condition is expected in the marker. At first look, the issue seems related to including a condition on the python version in the marker.

Cheers!

Reproducible steps

1. Configuration

pyproject.toml

[tool.poetry]
name = "aaa"
version = "0.0.0"

[tool.poetry.dependencies]
python = "~3.9"
numpy = [
    {version = ">=1.21.0, <=2.0.2", platform = "darwin" },
    {version = ">=1.20.0, <=2.0.2", markers = "python_version == \"3.9\" or platform_system == \"Linux\""},
]

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

2. Generate lockfile

Output poetry.lock

# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand.

[[package]]
name = "numpy"
version = "2.0.2"
description = "Fundamental package for array computing in Python"
optional = false
python-versions = ">=3.9"
groups = ["main"]
markers = "platform_system == \"Linux\""    <--- expected nothing
files = [
    {file = "numpy-2.0.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:51129a29dbe56f9ca83438b706e2e69a39892b5eda6cedcb6b0c9fdc9b0d3ece"},
    {file = "numpy-2.0.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:f15975dfec0cf2239224d80e32c3170b1d168335eaedee69da84fbe9f1f9cd04"},

[...]

3. Output using poetry-plugin-export==1.8.0

poetry export --format=requirements.txt

numpy==2.0.2 ; python_version == "3.9" \
    --hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \

[...]

4. Output using poetry-plugin-export==1.9.0

poetry export --format=requirements.txt

numpy==2.0.2 ; python_version == "3.9" and platform_system == "Linux" \
    --hash=sha256:0123ffdaa88fa4ab64835dcbde75dcdf89c453c922f18dced6e27c90d1d0ec5a \

[...]

Workarounds

Downgrading poetry==1.8.5. Downgrading poetry-plugin-export==1.8.0.

Poetry Installation Method

pip

Operating System

macOS, Linux

Poetry Version

2.1.1

Poetry Configuration

cache-dir = "/Users/joaomatias/Library/Caches/pypoetry"
data-dir = "/Users/joaomatias/Library/Application Support/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python"  # /Users/joaomatias/Library/Application Support/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = false
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/joaomatias/Library/Caches/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Paste the output of 'python -m sysconfig', over this line.

Example pyproject.toml

[tool.poetry]
name = "aaa"
version = "0.0.0"

[tool.poetry.dependencies]
python = "~3.9"
numpy = [
    {version = ">=1.21.0, <=2.0.2", platform = "darwin" },
    {version = ">=1.20.0, <=2.0.2", markers = "python_version == \"3.9\" or platform_system == \"Linux\""},
]

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

Poetry Runtime Logs

poetry-runtime.log
❯ poetry lock --regenerate -vvv
Loading configuration file /Users/joaomatias/Library/Application Support/pypoetry/config.toml
[findpython:findpython] Running script: ['/Users/joaomatias/Library/Caches/pypoetry/virtualenvs/ai-ds-benchmarks-yFIeOZjW-py3.9/bin/python', '-EsSc', 'import sys; print(sys.executable)']
Found: /Users/joaomatias/Library/Caches/pypoetry/virtualenvs/ai-ds-benchmarks-yFIeOZjW-py3.9/bin/python
[findpython:findpython] Running script: ['/Users/joaomatias/Library/Caches/pypoetry/virtualenvs/ai-ds-benchmarks-yFIeOZjW-py3.9/bin/python', '-EsSc', 'import platform; print(platform.python_version())']
Using virtualenv: /Users/joaomatias/Library/Caches/pypoetry/virtualenvs/aaa-yFIeOZjW-py3.9
Checking keyring availability: Checking if keyring is available
[keyring:keyring.backend] Loading KWallet
[keyring:keyring.backend] Loading SecretService
[keyring:keyring.backend] Loading Windows
[keyring:keyring.backend] Loading chainer
[keyring:keyring.backend] Loading libsecret
[keyring:keyring.backend] Loading macOS
Using keyring backend 'macOS Keyring'
Available
Updating dependencies
Resolving dependencies...
 1: fact: aaa is 0.0.0
 1: derived: aaa
 0: Duplicate dependencies for numpy
 0: Different requirements found for numpy (>=1.21.0,<=2.0.2) with markers (python_version == "3.9" or platform_system == "Linux") and sys_platform == "darwin" and numpy (>=1.20.0,<=2.0.2) with markers (python_version == "3.9" or platform_system == "Linux") and sys_platform != "darwin".
 1: Version solving took 0.001 seconds.
 1: Tried 1 solutions.
 0: Retrying dependency resolution with the following overrides ({Package('aaa', '0.0.0'): {'numpy': <Dependency numpy (>=1.21.0,<=2.0.2)>}}).
 1: fact: aaa is 0.0.0
 1: derived: aaa
 1: fact: aaa depends on numpy (>=1.21.0,<=2.0.2)
 1: selecting aaa (0.0.0)
 1: derived: numpy (>=1.21.0,<=2.0.2)
Creating new session for pypi.org
Source (PyPI): 34 packages found for numpy >=1.21.0,<=2.0.2
 1: selecting numpy (2.0.2)
 1: Version solving took 0.053 seconds.
 1: Tried 1 solutions.
 0: Retrying dependency resolution with the following overrides ({Package('aaa', '0.0.0'): {'numpy': <Dependency numpy (>=1.20.0,<=2.0.2)>}}).
 1: fact: aaa is 0.0.0
 1: derived: aaa
 1: fact: aaa depends on numpy (>=1.20.0,<=2.0.2)
 1: selecting aaa (0.0.0)
 1: derived: numpy (>=1.20.0,<=2.0.2)
Source (PyPI): 38 packages found for numpy >=1.20.0,<=2.0.2
 1: selecting numpy (2.0.2)
 1: Version solving took 0.001 seconds.
 1: Tried 1 solutions.
 0: Complete version solving took 0.056 seconds with 2 overrides
 0: Resolved with overrides: ({Package('aaa', '0.0.0'): {'numpy': <Dependency numpy (>=1.21.0,<=2.0.2)>}}), ({Package('aaa', '0.0.0'): {'numpy': <Dependency numpy (>=1.20.0,<=2.0.2)>}})

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expectedstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions