conda-forge / conda-forge/conda-forge.github.io
python version dependent package versions in noarch builds
- Dominant language
- JavaScript
- Stars
- 170
- Forks
- 320
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 5
Description
### Conda-forge documentation
- [x] I could not solve my problem using the conda-forge documentation.
### Installed packages
```shell
I am using the feedstock to build the binaries.
```
### Environment info
```shell
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:
```yaml
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.
Contributor guide
Research direction
Start with the recipe.yaml shown in the issue and reproduce the rattler-build noarch package using the listed Python 3.9 and 3.12 tests. Compare the finalized run dependencies and test-build output to determine whether the conditional sympy_plot_backends requirements are preserved. Done means documenting or correcting the dependency handling so the observed behavior is explained.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, yaml
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100