Skip to content

python version dependent package versions in noarch builds #2808

@zerothi

Description

@zerothi

Conda-forge documentation

  • I could not solve my problem using the conda-forge documentation.

Installed packages

I am using the feedstock to build the binaries.

Environment info

N/A

Issue

I am trying to construct a package with different package dependencies depending on the installed python version.

So a recipe.yaml (rattler-build) looking like this:

build:
  noarch: python
requirements:
  host:
    - python ${{ python_min }}.*
    - pip
    - setuptools_scm >=6.2
    - pyproject-metadata
  run:
    - python >=${{ python_min }},<=${{ python_max }}
    - if: match(python, "==3.9")
      then: sympy_plot_backends >=3.1.1,<3.3
      else: sympy_plot_backends >=3.4,<4
tests:
  python:
    python_version:
      - "3.9"
      - "3.12"

I know, this is bad practice, I am not the package maintainer, only release maintainer.

FYI, I can get this working if the recipes are build per python version, however, it is a pure python package, and so I wanted to return to a noarch build. This might be the problem...

I would suspect that the above incorporates in the conda-package the logic that says:

When I install a python 3.9 version, I get sympy_plot_backends >=3.1.1,<3.3.
When I install a python >3.9 version, I get sympy_plot_backends >=3.4,<4.

However, my suspicion is that the noarch build and it being built at python_min version means that the package only keeps the 3.9 package requirements and thus does not uphold the other requirement?

At least this is what is reflected in the CI:

│ Finalized run dependencies (dtumathtools-2025.2.0-pyhc364b38_3):
 │ ╭─────────────────────┬────────────────────────╮
 │ │ Name                ┆ Spec                   │
 │ ╞═════════════════════╪════════════════════════╡
 │ │ Run dependencies    ┆                        │
 │ │ jupyter             ┆ >=1.0.0                │
 │ │ matplotlib          ┆ >=3.8,<3.10            │
 │ │ numpy               ┆ >=1.24,<2              │
 │ │ python              ┆ >=3.9,<=3.12           │
 │ │                     ┆ (RE of [host: python]) │
 │ │ sympy               ┆ ~=1.12                 │
 │ │ sympy_plot_backends ┆ >=3.1.1,<3.3           │
 │ │                     ┆                        │
 │ │ Run constraints     ┆                        │
 │ │ colorcet            ┆ *                      │
 │ │ ipyevents           ┆ *                      │
 │ │ ipympl              ┆ >=0.7.0                │
 │ │ ipywidgets_bokeh    ┆ *                      │
 │ │ k3d                 ┆ >=2.9.7                │
 │ │ mayavi              ┆ ~=4.8,>=4.8.2          │
 │ │ panel               ┆ >=1.0.0                │
 │ │ plotly              ┆ >=4.14.3               │
 │ │ pyqt                ┆ ~=5.15.9               │
 │ │ vtk                 ┆ *                      │
 │ ╰─────────────────────┴────────────────────────╯

In the test-build I get:

...
 │ │ │ │ python                        ┆ 3.12.0       ┆ hab00c5b_0_cpython   ┆ conda-forge ┆   30.64 MiB │
...
 │ │ │ │ sympy_plot_backends           ┆ 3.2.0        ┆ pyhd8ed1ab_0         ┆ conda-forge ┆  208.63 KiB │
...

which clearly shows this behavior.

I would say this is my problem, but it's still a bit problematic that conda eats the recipe without problems since it shows a problem in the dependency detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions