Skip to content

'platform_machine' marker issue when adding opencv to dependencies #10267

@ostefano

Description

@ostefano

Description

The lock file produced when opencv-python is present has all markers set to platform_machine == \"aarch64\"" while opencv-python does not enforce the platform when a recent version of numpy is installed (https://github.com/opencv/opencv-python/blob/4.x/pyproject.toml).

Example (random entry):

[[package]]
name = "idna"
version = "3.10"
description = "Internationalized Domain Names in Applications (IDNA)"
optional = false
python-versions = ">=3.6"
groups = ["main"]
markers = "platform_system == \"Linux\" and platform_machine == \"aarch64\""
files = [
    {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"},
    {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"},
]

[package.extras]
all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"]

This has the unintended effect that when using poetry export the aarch64 markers percolate to requirements.txt.

Once I remove opencv-python the poetry.lock file looks much better, and there is no platform constraint:

[[package]]
name = "idna"
version = "3.10"
description = "Internationalized Domain Names in Applications (IDNA)"
optional = false
python-versions = ">=3.6"
groups = ["main"]
files = [
    {file = "idna-3.10-py3-none-any.whl", hash = "sha256:946d195a0d259cbba61165e88e65941f16e9b36ea6ddb97f00452bae8b1287d3"},
    {file = "idna-3.10.tar.gz", hash = "sha256:12f65c9b470abda6dc35cf8e63cc574b1c52b11df2c86030af0ac09b01b13ea9"},
]

[package.extras]
all = ["flake8 (>=7.1.1)", "mypy (>=1.11.2)", "pytest (>=8.3.2)", "ruff (>=0.6.2)"]

Workarounds

No workaround at the moment.

Poetry Installation Method

install.python-poetry.org

Operating System

OSX / Ubuntu 22.04

Poetry Version

2.1.1

Poetry Configuration

cache-dir = "/Users/username/Library/Caches/pypoetry"
data-dir = "/Users/username/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/username/Library/Application Support/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/username/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

[project]
name = "project"
version = "3.0.1"
license = "AGPL-3.0-only"
readme = "README.md"
requires-python = ">=3.9,<3.13"
dependencies = [
    "orjson",
    "psutil",
    "tornado",
    "beautifulsoup4",
    "jinja2",
    "markdownify",
    "pymisp",
    "publicsuffixlist",
    "setuptools",
    "opencv-python",
]

[tool.poetry]
packages = [{include = "project"}]

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

Poetry Runtime Logs

poetry-runtime.log
Paste the output of 'poetry -vvv <command>', over this line.

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